Made tooltip overlay switch visibility only when changed.
Added Tooltip.SetVisibility. Fixed bug where no events where triggered for change in visibility.
This commit is contained in:
parent
75fce53716
commit
b9534ee255
@ -72,7 +72,6 @@ func (c *context) Overlays() *Overlays { return c.overlays }
|
||||
func (c *context) Renderer() Renderer { return c.renderer }
|
||||
|
||||
func (c *context) ShowTooltip(t string) {
|
||||
c.overlays.Show(uiDefaultTooltipOverlay)
|
||||
c.tooltip.Text = t
|
||||
}
|
||||
|
||||
|
@ -95,10 +95,8 @@ func (o *Overlays) Render(ctx Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func (o *Overlays) Show(name string) {
|
||||
o.visible[name] = true
|
||||
}
|
||||
func (o *Overlays) SetVisibility(name string, visible bool) { o.setVisibility(name, visible) }
|
||||
|
||||
func (o *Overlays) Toggle(name string) {
|
||||
o.visible[name] = !o.visible[name]
|
||||
}
|
||||
func (o *Overlays) Show(name string) { o.SetVisibility(name, true) }
|
||||
|
||||
func (o *Overlays) Toggle(name string) { o.SetVisibility(name, false) }
|
||||
|
6
ui/ui.go
6
ui/ui.go
@ -50,8 +50,12 @@ func RunWait(r Renderer, s *Style, view Control, wait bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
ctx.overlays.Hide("ui-default-tooltip")
|
||||
tooltip := ctx.tooltip.Text
|
||||
ctx.tooltip.Text = ""
|
||||
r.PushEvents(ctx, wait)
|
||||
if ctx.tooltip.Text != tooltip {
|
||||
ctx.overlays.SetVisibility(uiDefaultTooltipOverlay, ctx.tooltip.Text != "")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user