Interface Tooltip
- All Known Implementing Classes:
Tooltip.Custom, Tooltip.Lines
HasTooltip.setTooltip(Tooltip).
The host shows a tooltip once the pointer has rested on its component for the host's tooltip delay, or at once when the pointer moves straight from another component's tooltip. The delay is the one the adapter sets, else the theme's "tooltip.delay", else 500L milliseconds. It moves with the pointer: its top-left corner sits "tooltip.offset.x" units right of and "tooltip.offset.y" units below the pointer's whole-unit position (12 right and 12 above by default), flipped to the left side when it would leave the host on the right, and kept inside the host. It hides while a drag is in progress. A tooltip draws above the screen and every overlay, and takes no input.
There are two kinds. Tooltip.Lines, made by text(Text), text(String) and lines(List),
is drawn by Strata: on the "tooltip.background" paint inside the "tooltip.padding" insets, 4 units on
every side by default, with its plain parts in the "tooltip.text" text style and styled parts changing it
(see Text). Tooltip.Custom, made by of(Function), is a component built afresh each time the tooltip shows,
drawn with no box around it. Engine adapters can offer factory methods that build tooltips from engine objects,
such as the lines an engine shows for one of its items.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordA component built when the tooltip appears.static final recordLines of text, resolved against the theme's tooltip style each time the tooltip appears. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longHow long, in milliseconds, the pointer rests on a component before its tooltip shows, unless the adapter or the theme sets another delay.static final StringStyle key for the box behind aTooltip.Linestooltip (paint, optional).static final StringStyle key for placing a tooltip below its component rather than beside the pointer (metric, optional): any value but 0 turns it on.static final StringStyle key for the gap of a tooltip placed below its component (metric, optional), in UI units.static final StringStyle key for the overlap of a tooltip placed below its component (metric, optional), in UI units.static final StringStyle key for how long the pointer rests on a component before its tooltip shows (metric, optional), in milliseconds.static final StringStyle key for a second layer drawn over the "tooltip.background" of aTooltip.Linestooltip, such as an edge (paint, optional).static final StringStyle key for where a tooltip's left edge sits, right of the pointer (metric, optional), in UI units.static final StringStyle key for where a tooltip's top edge sits, below the pointer (metric, optional), in UI units; a negative value puts it above.static final StringStyle key for how far the background and frame of aTooltip.Linestooltip reach past its box (insets, optional), for paints whose images have a margin of their own.static final StringStyle key for the space between aTooltip.Linestooltip's edges and its text (insets, optional).static final StringStyle key for the text of aTooltip.Linestooltip (text style, optional). -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic TooltipReturns a tooltip of lines.static Tooltipof(Function<ComponentFactory, ? extends Component<?>> builder) Returns a tooltip whose content is a component, built again each time the tooltip appears.static TooltipReturns a tooltip of literal text in the theme's tooltip style.static TooltipReturns a tooltip of text.
-
Field Details
-
STYLE_BACKGROUND
Style key for the box behind aTooltip.Linestooltip (paint, optional). If it is missing, the box is a dark fill with a one-unit purple edge.- See Also:
-
STYLE_TEXT
Style key for the text of aTooltip.Linestooltip (text style, optional). Falls back to the default style.- See Also:
-
STYLE_PADDING
Style key for the space between aTooltip.Linestooltip's edges and its text (insets, optional). Defaults to 4 on every side.- See Also:
-
STYLE_FRAME
Style key for a second layer drawn over the "tooltip.background" of aTooltip.Linestooltip, such as an edge (paint, optional). Defaults to none.- See Also:
-
STYLE_OUTSET
Style key for how far the background and frame of aTooltip.Linestooltip reach past its box (insets, optional), for paints whose images have a margin of their own. The box, which is placed and kept inside the host, is the text and its padding. Defaults to none.- See Also:
-
STYLE_DELAY
-
STYLE_OFFSET_X
Style key for where a tooltip's left edge sits, right of the pointer (metric, optional), in UI units. When flipped to the left side, its right edge sits this far left of the pointer. Defaults to 12.- See Also:
-
STYLE_OFFSET_Y
Style key for where a tooltip's top edge sits, below the pointer (metric, optional), in UI units; a negative value puts it above. Defaults to -12.- See Also:
-
STYLE_BELOW
Style key for placing a tooltip below its component rather than beside the pointer (metric, optional): any value but 0 turns it on. Defaults to 0. The left edge still follows "tooltip.offset.x". With the pointer at heightp, the component's top att, its bottom atband its heighth, the box's top isp + e(|p + o - t|), wheree(d)eases fromh - oat a distance of 0 togat a distance ofhor more and rounds to a whole unit,ois "tooltip.below.overlap" andgis "tooltip.below.gap". So the box sits just below the component and moves a little with the pointer. When the host has no room for the box belowb + h, lessg, the box's bottom goes top - e(|p + o - b|)instead, above the pointer.- See Also:
-
STYLE_BELOW_OVERLAP
Style key for the overlap of a tooltip placed below its component (metric, optional), in UI units. See "tooltip.below". Defaults to 3.- See Also:
-
STYLE_BELOW_GAP
Style key for the gap of a tooltip placed below its component (metric, optional), in UI units. See "tooltip.below". Defaults to 5.- See Also:
-
DEFAULT_DELAY_MILLIS
static final long DEFAULT_DELAY_MILLISHow long, in milliseconds, the pointer rests on a component before its tooltip shows, unless the adapter or the theme sets another delay.- See Also:
-
-
Method Details
-
text
-
text
-
lines
-
of
Returns a tooltip whose content is a component, built again each time the tooltip appears.- Parameters:
builder- makes the content with the host's factory- Returns:
- the tooltip
-