diff --git a/ui/context.go b/ui/context.go index 9e50161..d37bd5c 100644 --- a/ui/context.go +++ b/ui/context.go @@ -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 } diff --git a/ui/overlays.go b/ui/overlays.go index fffa909..e8edaaf 100644 --- a/ui/overlays.go +++ b/ui/overlays.go @@ -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) } diff --git a/ui/ui.go b/ui/ui.go index ac710f4..040050d 100644 --- a/ui/ui.go +++ b/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 }