diff --git a/chart/candlestick_chart.go b/chart/candlestick_chart.go index 0c8b72f..0b8ab0a 100644 --- a/chart/candlestick_chart.go +++ b/chart/candlestick_chart.go @@ -67,6 +67,7 @@ type mktCore struct { candles []Candle view *MarketView from, to int + act int // keyboard or click activation, mark plus one; zero is none lo, hi float64 base float64 // percent mode divides by this close; 0 is prices dec int @@ -277,9 +278,7 @@ func (m *mktCore) spec() ChartSpec { } if d := m.opts.Drawings; d != nil { spec.Activate = func(i int) { - if !d.Locked && d.Tool != ToolSelect { - d.place(m, DrawingPoint{m.candles[i].Time, m.candles[i].Close}) - } + m.act = i + 1 } } spec.Readout = m.readout diff --git a/chart/chart_tooltip.go b/chart/chart_tooltip.go index 28c239c..0f088ea 100644 --- a/chart/chart_tooltip.go +++ b/chart/chart_tooltip.go @@ -47,7 +47,7 @@ func ChartTooltip(c *ui.Context, x, y float32, lines []ChartTooltipLine) *ui.Ele } var tip *ui.Element ui.Overlay(c, func() { - tip = ui.Column(c).Absolute().Left(left).Top(top).Size(w, h).Role(ui.RoleNone) + tip = ui.Column(c).Absolute().Left(left).Top(top).Size(w, h).Role(ui.RoleNone).PassThrough() core.OverlayStyle(c, tip, core.OverlayEnter(c, tip)) tip.Children(func() { inner := max(1, w-2*pad) @@ -60,8 +60,8 @@ func ChartTooltip(c *ui.Context, x, y float32, lines []ChartTooltipLine) *ui.Ele _, lh[i] = c.MeasureText(width, ui.Span{Text: l.Text, Size: size, Weight: chartTipWeight(i)}) content += lh[i] } - ui.Scroll(c).Fill().Padding(pad).Children(func() { - ui.Box(c).Width(inner).Height(content).Shrink(0).Draw(func(p *ui.Painter, r ui.Rect) { + ui.Scroll(c).Fill().Padding(pad).PassThrough().Children(func() { + ui.Box(c).Width(inner).Height(content).Shrink(0).PassThrough().Draw(func(p *ui.Painter, r ui.Rect) { at := r.Y for i, l := range lines { tx, width := r.X, inner diff --git a/chart/market_input.go b/chart/market_input.go index 8db83ed..9d8976e 100644 --- a/chart/market_input.go +++ b/chart/market_input.go @@ -63,6 +63,11 @@ func (m *mktCore) input(plot *ui.Element) { used := false if d := m.opts.Drawings; d != nil { used = d.input(m, plot, g, x, y, over, held, dx, dy) + // A click is placed by input at the pointer; only a key press lands here. + if i := m.act - 1; i >= 0 && !used && !d.Locked && d.Tool != ToolSelect { + d.place(m, DrawingPoint{m.candles[i].Time, m.candles[i].Close}) + used = true + } } if !used { m.alertsKeyboard(plot)