XU XUv0.13.1
中文

UI / WIDGETS / Feedback

Tooltip

Add a short explanation to an anchor

Run the Xu example

The example executes in the browser using the Xu/WASM runtime.

What to try

Hover or focus the help button.

Usage notes

Add context without requiring an action inside the tooltip. Support both hover and keyboard focus and keep essential information outside the tooltip too.

Create through Screen

The Screen constructor returns a node ID. Pass that ID to Screen layout, state and event APIs. It is separate from the standalone control object documented below.

Native Xu setup fragment: call configure during initialization of an existing Screen. See the complete example for window creation, event dispatch and cleanup.

#ui/widgets

fn configure(screen $&widgets.Screen) int {
    anchor := screen.button("Preferences") or >>
    screen.place(anchor,24.0,24.0,180.0,40.0) or >>
    id := screen.tooltip(anchor,"Project name") or >>
    << id
}

($&Screen) tooltip

XuAPI
pub fn (s $&Screen) tooltip(anchor int,text string) int

Purpose

Create Tooltip in Screen and return the component node ID; throw on creation failure.

Parameters

s $&Screen
The Screen instance used by this call (exclusive borrow).
anchor int
anchor (int)
text string
text (string)

Returns

int — component node ID for place and other Screen methods.

Placement, state and events

The application owns the component. Screen.place positions nodes; Screen.set_enabled and Screen.set_visible control availability and visibility. Present again after state changes, handle or errors, and keep topology changes outside paint callbacks. ToastHost uses its own queue API.

Action · Styles · UI lifecycle and styling guide

Screen.place · Screen.set_enabled · Screen.set_visible

Standalone control object API

These types and methods support applications that manage control objects, input and painting directly. Their receiver is a control object, not a Screen node ID. For Screen usage, use the constructor above and the Screen methods in the Widgets module.

struct Tooltip

XuAPI
pub struct Tooltip {

}

Purpose

The host forwards anchor pointer/focus events and calls tick at next_tick. No polling task is started. Geometry is in full canvas coordinates.

Public fields

This type has no public fields.

(&Tooltip) id

XuAPI
pub fn (t &Tooltip) id() int

Purpose

Return the unique integer ID of the element or control.

Parameters

t &Tooltip
The Tooltip instance used by this call (borrow).

Returns

int — a value of this type

(&Tooltip) bounds

XuAPI
pub fn (t &Tooltip) bounds() layout.Rect

Purpose

Return the bounding Rectangle of the control or geometry.

Parameters

t &Tooltip
The Tooltip instance used by this call (borrow).

Returns

layout.Rect — a value of this type

(&Tooltip) is_enabled

XuAPI
pub fn (t &Tooltip) is_enabled() bool

Purpose

Return whether the control is currently enabled.

Parameters

t &Tooltip
The Tooltip instance used by this call (borrow).

Returns

bool — true or false

(&Tooltip) is_selectable

XuAPI
pub fn (t &Tooltip) is_selectable() bool

Purpose

Operation on &Tooltip: whether it is selectable.

Parameters

t &Tooltip
The Tooltip instance used by this call (borrow).

Returns

bool — true or false

($&Tooltip) set_selectable

XuAPI
pub fn (t $&Tooltip) set_selectable(selectable bool)

Purpose

Operation on $&Tooltip: set selectable.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
selectable bool
selectable (bool)

Returns

This call does not return a value.

($&Tooltip) set_text

XuAPI
pub fn (t $&Tooltip) set_text(context &draw.Context,text &string) int

Purpose

Operation on $&Tooltip: set text. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
context &draw.Context
context (read-only borrow; caller keeps the original; type &draw.Context)
text &string
text (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

(&Tooltip) has_popup_open

XuAPI
pub fn (t &Tooltip) has_popup_open() bool

Purpose

Operation on &Tooltip: whether it has popup open.

Parameters

t &Tooltip
The Tooltip instance used by this call (borrow).

Returns

bool — true or false

(&Tooltip) popup_bounds

XuAPI
pub fn (t &Tooltip) popup_bounds() layout.Rect

Purpose

Operation on &Tooltip: popup bounds.

Parameters

t &Tooltip
The Tooltip instance used by this call (borrow).

Returns

layout.Rect — a value of this type

(&Tooltip) selected_text

XuAPI
pub fn (t &Tooltip) selected_text() string

Purpose

Operation on &Tooltip: selected text.

Parameters

t &Tooltip
The Tooltip instance used by this call (borrow).

Returns

string — result string

(&Tooltip) copy_selection

XuAPI
pub fn (t &Tooltip) copy_selection() int

Purpose

Operation on &Tooltip: copy selection.

Parameters

t &Tooltip
The Tooltip instance used by this call (borrow).

Returns

int — a value of this type

(&Tooltip) cursor

XuAPI
pub fn (t &Tooltip) cursor() int

Purpose

Execute cursor on &Tooltip.

Parameters

t &Tooltip
The Tooltip instance used by this call (borrow).

Returns

int — a value of this type

($&Tooltip) set_viewport

XuAPI
pub fn (t $&Tooltip) set_viewport(viewport &layout.Rect)

Purpose

Operation on $&Tooltip: set viewport.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
viewport &layout.Rect
viewport (read-only borrow; caller keeps the original; type &layout.Rect)

Returns

This call does not return a value.

($&Tooltip) set_locale

XuAPI
pub fn (t $&Tooltip) set_locale(locale &Locale) int

Purpose

Operation on $&Tooltip: set locale. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
locale &Locale
locale (read-only borrow; caller keeps the original; type &Locale)

Returns

int — a value of this type

(&Tooltip) is_open

XuAPI
pub fn (t &Tooltip) is_open() bool

Purpose

Return whether the overlay, menu or dialog is currently open.

Parameters

t &Tooltip
The Tooltip instance used by this call (borrow).

Returns

bool — true or false

(&Tooltip) is_visible

XuAPI
pub fn (t &Tooltip) is_visible() bool

Purpose

Operation on &Tooltip: whether it is visible.

Parameters

t &Tooltip
The Tooltip instance used by this call (borrow).

Returns

bool — true or false

(&Tooltip) opacity

XuAPI
pub fn (t &Tooltip) opacity() f64

Purpose

Execute opacity on &Tooltip.

Parameters

t &Tooltip
The Tooltip instance used by this call (borrow).

Returns

f64 — a value of this type

(&Tooltip) needs_paint

XuAPI
pub fn (t &Tooltip) needs_paint() bool

Purpose

Return whether the control needs repainting; call painted after painting to clear the flag.

Parameters

t &Tooltip
The Tooltip instance used by this call (borrow).

Returns

bool — true or false

($&Tooltip) painted

XuAPI
pub fn (t $&Tooltip) painted()

Purpose

Acknowledge the painted frame and clear the dirty flag; this is not a query.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&Tooltip) set_delay

XuAPI
pub fn (t $&Tooltip) set_delay(delay time.Duration) int

Purpose

Operation on $&Tooltip: set delay. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
delay time.Duration
delay (time.Duration)

Returns

int — a value of this type

($&Tooltip) set_geometry

XuAPI
pub fn (t $&Tooltip) set_geometry(anchor &layout.Rect,size &layout.Size,viewport &layout.Rect) int

Purpose

Operation on $&Tooltip: set geometry. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
anchor &layout.Rect
anchor (read-only borrow; caller keeps the original; type &layout.Rect)
size &layout.Size
size (read-only borrow; caller keeps the original; type &layout.Size)
viewport &layout.Rect
viewport (read-only borrow; caller keeps the original; type &layout.Rect)

Returns

int — a value of this type

($&Tooltip) set_placement

XuAPI
pub fn (t $&Tooltip) set_placement(placement &OverlayPlacement) int

Purpose

Operation on $&Tooltip: set placement. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
placement &OverlayPlacement
placement (read-only borrow; caller keeps the original; type &OverlayPlacement)

Returns

int — a value of this type

($&Tooltip) set_enabled

XuAPI
pub fn (t $&Tooltip) set_enabled(enabled bool) int

Purpose

Operation on $&Tooltip: set enabled. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
enabled bool
enabled (bool)

Returns

int — a value of this type

($&Tooltip) set_blocked

XuAPI
pub fn (t $&Tooltip) set_blocked(blocked bool,now time.Instant) int

Purpose

Interactive surfaces take priority over passive help. Suspend immediately, retain the logical trigger, and require a fresh delay when the surface exits. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
blocked bool
blocked (bool)
now time.Instant
now (time.Instant)

Returns

int — a value of this type

($&Tooltip) set_focus

XuAPI
pub fn (t $&Tooltip) set_focus(focused bool,now time.Instant) int

Purpose

Operation on $&Tooltip: set focus. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
focused bool
focused (bool)
now time.Instant
now (time.Instant)

Returns

int — a value of this type

($&Tooltip) dismiss

XuAPI
pub fn (t $&Tooltip) dismiss(now time.Instant,reduced_motion bool) int

Purpose

Execute dismiss on $&Tooltip. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
now time.Instant
now (time.Instant)
reduced_motion bool
reduced_motion (bool)

Returns

int — a value of this type

($&Tooltip) input

XuAPI
pub fn (t $&Tooltip) input(event &ui.InputEvent) Action

Purpose

Process routed mouse, keyboard, or touch input events. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
event &ui.InputEvent
event (read-only borrow; caller keeps the original; type &ui.InputEvent)

Returns

Action — input result with kind, id, repaint and focus requests.

($&Tooltip) route

XuAPI
pub fn (t $&Tooltip) route(kind int,event &ui.InputEvent) Action

Purpose

Route and dispatch the input event to matching targets. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
kind int
kind tag (int)
event &ui.InputEvent
event (read-only borrow; caller keeps the original; type &ui.InputEvent)

Returns

Action — input result with kind, id, repaint and focus requests.

($&Tooltip) tick

XuAPI
pub fn (t $&Tooltip) tick(now time.Instant,reduced_motion bool) bool

Purpose

Advance animation clock and state transition step. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
now time.Instant
now (time.Instant)
reduced_motion bool
reduced_motion (bool)

Returns

bool — true or false

(&Tooltip) next_tick

XuAPI
pub fn (t &Tooltip) next_tick(now time.Instant) time.Instant

Purpose

Operation on &Tooltip: next tick. Throws on failure; handle the error or propagate it to the caller.

Parameters

t &Tooltip
The Tooltip instance used by this call (borrow).
now time.Instant
now (time.Instant)

Returns

time.Instant — a value of this type

(&Tooltip) paint_styled

XuAPI
pub fn (t &Tooltip) paint_styled(frame $&draw.Frame,label $&StyledLabel,styles &Styles) int

Purpose

Operation on &Tooltip: paint styled. Throws on failure; handle the error or propagate it to the caller.

Parameters

t &Tooltip
The Tooltip instance used by this call (borrow).
frame $&draw.Frame
frame (exclusive borrow; may modify the original; type $&draw.Frame)
label $&StyledLabel
label (exclusive borrow; may modify the original; type $&StyledLabel)
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)

Returns

int — a value of this type

($&Tooltip) paint_content_styled

XuAPI
pub fn (t $&Tooltip) paint_content_styled(frame $&draw.Frame,styles &Styles) int

Purpose

Operation on $&Tooltip: paint content styled. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
frame $&draw.Frame
frame (exclusive borrow; may modify the original; type $&draw.Frame)
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)

Returns

int — a value of this type

($&Tooltip) paint_popup_styled

XuAPI
pub fn (t $&Tooltip) paint_popup_styled(frame $&draw.Frame,styles &Styles) int

Purpose

Operation on $&Tooltip: paint popup styled. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
frame $&draw.Frame
frame (exclusive borrow; may modify the original; type $&draw.Frame)
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)

Returns

int — a value of this type

($&Tooltip) set_style

XuAPI
pub fn (t $&Tooltip) set_style(style &ControlStyle) int

Purpose

Operation on $&Tooltip: set style. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
style &ControlStyle
style (read-only borrow; caller keeps the original; type &ControlStyle)

Returns

int — a value of this type

($&Tooltip) set_motion

XuAPI
pub fn (t $&Tooltip) set_motion(spec &MotionSpec) int

Purpose

Operation on $&Tooltip: set motion. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Tooltip
The Tooltip instance used by this call (exclusive borrow).
spec &MotionSpec
spec (read-only borrow; caller keeps the original; type &MotionSpec)

Returns

int — a value of this type

Complete native example

Component Workshop · Back to Widgets