type HoverTooltip struct {
// suppressed is the control a click just hid the tooltip of; it stays
// hidden until the pointer leaves that control, as Base UI's closeOnClick
// does.
// focus shows the hint of the keyboard-focused control too, without a delay.
// shown is the control whose tooltip the last Paint drew, so a press or an
// explicit Dismiss can suppress that control until the pointer leaves.
}
HoverTooltip shows the Hint of whichever hit the pointer has rested on for a
while, as a tooltip beside it. The application keeps one value, declares
Hint on the hits that deserve a tooltip (an icon-only button is the usual
case) and calls Paint last in each frame, after everything the tooltip may
overlap. Holding no timer or goroutine, it asks the canvas for one frame at
the moment a tooltip is due and for nothing while idle.
Methods
Dismiss#
func (hover *HoverTooltip) Dismiss() bool
Dismiss hides the tooltip that is showing and keeps it hidden until the
pointer leaves that control, returning whether anything was showing. The
application calls it when Escape reaches the tooltip's control.
Paint#
func (hover *HoverTooltip) Paint(canvas *ui.Canvas, theme ui.Theme, viewport ui.Rect, options TooltipOptions, delay time.Duration) bool
Paint draws the tooltip of the hovered hit once it has been hovered for
delay, and reports whether it did. The tooltip goes below the control, or
above it when the viewport has no room below (see PlaceOverlay). It stays hidden while a button
is pressed and for hits without a Hint.
ShowOnFocus#
func (hover *HoverTooltip) ShowOnFocus()
ShowOnFocus makes a keyboard-focused control with a Hint show its tooltip at
once, as a web tooltip trigger does on focus-visible. It is off by default
because some applications use Hint only as an accessibility description.
Showing#
func (hover *HoverTooltip) Showing() ui.ID
Showing returns the control whose tooltip the last Paint drew, or zero.