Tooltip
在核心精确控制的延迟后显示辅助信息,并支持 Provider 级预热。
正在加载交互演示…
func TooltipExample() *ui.Element {
provider := ui.NewTooltipProvider(ui.TooltipProviderProps{Delay: 500})
tooltip := ui.NewTooltip().Side("top")
return provider.Root().Child(
tooltip.Root().Children(
tooltip.Trigger().Child("Hover me"),
tooltip.Positioner().Child(
tooltip.Popup().Child("Helpful information"),
),
),
)
}#导入
从 github.com/egoist/quickgui/go/ui 导入 ui。
import (
"github.com/egoist/quickgui/go/ui"
)#用法
func TooltipExample() *ui.Element {
provider := ui.NewTooltipProvider(ui.TooltipProviderProps{Delay: 500})
tooltip := ui.NewTooltip().Side("top")
return provider.Root().Child(
tooltip.Root().Children(
tooltip.Trigger().Child("Hover me"),
tooltip.Positioner().Child(
tooltip.Popup().Child("Helpful information"),
),
),
)
}#结构
tooltip.Providertooltip.Roottooltip.Triggertooltip.Portaltooltip.Positionertooltip.Popuptooltip.Arrow
#API 参考
展开条目查看说明和完整签名。短横线表示声明中未记录默认值。
NewTooltip
查看源码ui.NewTooltip(props ...TooltipRootProps) *TooltipComponentNewTooltip declares a Tooltip instance. Optional props provide initial settings.
ChildrenComponent—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
Component查看源码Openfunc() bool—
DefaultOpenbool—
OnOpenChangefunc(bool, *native.Event)—
Disabledbool—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
bool查看源码Hoverable*bool—
TrackCursorAxisTooltipCursorAxis—
OnPlacementChangefunc(AnchorPlacementDetails, *native.Event)—
Callback for placement change. The signature below lists the event payload.
func(AnchorPlacementDetails, *native.Event)查看源码SideTooltipSide—
AlignTooltipAlign—
SideOffset*float64—
CollisionPadding*float64—
Tooltip.Open
查看源码tooltip.Open(value any) *TooltipComponentControlled visibility of the panel or overlay. Pair with the open-change callback.
Tooltip.DefaultOpen
查看源码tooltip.DefaultOpen(value bool) *TooltipComponentInitial visibility when the component owns its open state.
Tooltip.OnOpenChange
查看源码tooltip.OnOpenChange(value func(bool, *native.Event)) *TooltipComponentReports a requested visibility change, including dismissal.
Tooltip.Disabled
查看源码tooltip.Disabled(value bool) *TooltipComponentPrevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
Tooltip.Hoverable
查看源码tooltip.Hoverable(value bool) *TooltipComponentAllows the pointer to cross into the tooltip without closing it.
Tooltip.TrackCursorAxis
查看源码tooltip.TrackCursorAxis(value TooltipCursorAxis) *TooltipComponentAxis along which the floating surface follows the pointer.
Tooltip.OnPlacementChange
查看源码tooltip.OnPlacementChange(value func(AnchorPlacementDetails, *native.Event)) *TooltipComponentCallback for placement change. The signature below lists the event payload.
Tooltip.Side
查看源码tooltip.Side(value TooltipSide) *TooltipComponentPreferred placement side before collision handling.
Tooltip.Align
查看源码tooltip.Align(value TooltipAlign) *TooltipComponentPreferred alignment on the placement cross-axis.
Tooltip.SideOffset
查看源码tooltip.SideOffset(value float64) *TooltipComponentDistance from the anchor on the chosen side, in logical pixels.
Tooltip.CollisionPadding
查看源码tooltip.CollisionPadding(value float64) *TooltipComponentSpace reserved between the positioned surface and the available viewport edges.
Tooltip.Root
查看源码tooltip.Root() *ElementConfigures root for this part. The declared type and source define the accepted value.
Tooltip.Trigger
查看源码tooltip.Trigger(options ...TooltipTriggerProps) *ElementConfigures trigger for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)查看源码Styleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
any查看源码ChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildren查看源码Disabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
any查看源码Rolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
TabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64查看源码OnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)查看源码OnDoubleClickfunc(*native.Event)—
OnContextMenufunc(*native.Event)—
OnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
OnMouseLeavefunc(*native.Event)—
OnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
Elementstring—
Delayany—
CloseDelayany—
CloseOnClick*bool—
Tooltip.Positioner
查看源码tooltip.Positioner(options ...TooltipPositionerProps) *ElementConfigures positioner for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)查看源码Styleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
any查看源码ChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildren查看源码Disabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
any查看源码Rolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
TabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64查看源码OnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)查看源码OnDoubleClickfunc(*native.Event)—
OnContextMenufunc(*native.Event)—
OnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
OnMouseLeavefunc(*native.Event)—
OnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
SideTooltipSide—
AlignTooltipAlign—
SideOffset*float64—
CollisionPadding*float64—
Tooltip.Portal
查看源码tooltip.Portal(options ...PartProps) *ElementConfigures portal for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)查看源码Styleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
any查看源码ChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildren查看源码Disabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
any查看源码Rolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
TabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64查看源码OnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)查看源码OnDoubleClickfunc(*native.Event)—
OnContextMenufunc(*native.Event)—
OnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
OnMouseLeavefunc(*native.Event)—
OnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
Tooltip.Popup
查看源码tooltip.Popup(options ...PartProps) *ElementConfigures popup for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)查看源码Styleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
any查看源码ChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildren查看源码Disabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
any查看源码Rolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
TabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64查看源码OnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)查看源码OnDoubleClickfunc(*native.Event)—
OnContextMenufunc(*native.Event)—
OnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
OnMouseLeavefunc(*native.Event)—
OnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
Tooltip.Arrow
查看源码tooltip.Arrow(options ...PartProps) *ElementConfigures arrow for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)查看源码Styleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
any查看源码ChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildren查看源码Disabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
any查看源码Rolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
TabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64查看源码OnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)查看源码OnDoubleClickfunc(*native.Event)—
OnContextMenufunc(*native.Event)—
OnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
OnMouseLeavefunc(*native.Event)—
OnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
Element
查看源码part.Child(content).Style(style)Every part returns a fluent element. Strings, numbers, elements, and deferred child factories compose directly.
ChildChild(child any) *Element—
Child appends content and returns this element. Content can be an element, native node, scalar, accessor, or node-returning construction callback.
Child(child any) *Element查看源码ChildrenChildren(children ...any) *Element—
Children appends multiple children in order without replacing existing content. It also accepts []any, []*Element, and []*native.Node slices as arguments. Read the retained child nodes through element.Node.Children.
Children(children ...any) *Element查看源码StyleStyle(style StyleBuilder) *Element—
Style merges a reusable style. Scalar accessors retain independent native bindings.
Style(style StyleBuilder) *Element查看源码OnClickOnClick(handler func()) *Element—
RefRef(handler func(*native.Node)) *Element—
Ref exposes the native handle once at this point in the declaration chain.
Ref(handler func(*native.Node)) *Element查看源码