Skip to main content

RawTooltip

Struct RawTooltip 

Source
pub struct RawTooltip {
Show 14 fields pub key: Option<KeyRef>, pub semantics_tooltip: Option<String>, pub tooltip_builder: TooltipComponentBuilder, pub hover_delay: Duration, pub touch_delay: Duration, pub dismiss_delay: Duration, pub enable_tap_to_dismiss: bool, pub trigger_mode: TooltipTriggerMode, pub enable_feedback: bool, pub on_triggered: Option<TooltipTriggeredCallback>, pub animation_style: AnimationStyle, pub position_delegate: Option<TooltipPositionDelegate>, pub ignore_pointer: bool, pub child: WidgetRef,
}
Expand description

A widget that wraps a child to display an informative overlay in response to user interactions, such as hovering or long-pressing.

Tooltips provide essential context by displaying text labels or brief descriptions that explain the function of a button or other user interface elements.

The tooltip can be triggered in several ways:

See also:

Fields§

§key: Option<KeyRef>§semantics_tooltip: Option<String>

The text to display in the tooltip’s semantics announcement.

This string is used by assistive technologies, most notably screen readers like TalkBack and VoiceOver, to describe the tooltip’s purpose.

Providing a non-empty string adds a Semantics tooltip string for assistive technologies. If the tooltip should not have a semantic description, this property must be explicitly set to None.

§tooltip_builder: TooltipComponentBuilder

Builds the widget that will be displayed in the tooltip’s overlay.

The animation parameter is an Animation that maps to the tooltip’s show and hide animation. Its value goes from 0.0 to 1.0 when the tooltip is shown, and from 1.0 to 0.0 when it is hidden.

This animation can be used to create custom transitions for the tooltip, such as fading or scaling, by wrapping the tooltip’s content in a FadeTransition or ScaleTransition and using the provided animation.

The characteristics of the animation, such as its duration and curve, can be customized using the animation_style property.

§hover_delay: Duration

The length of time that a pointer must hover over a tooltip’s widget before the tooltip will be shown.

Defaults to 0 milliseconds (the tooltip is shown immediately upon hover).

§touch_delay: Duration

The length of time that the tooltip will be shown after a long press is released (if trigger_mode is TooltipTriggerMode::LongPress) or a tap is released (if trigger_mode is TooltipTriggerMode::Tap).

This property does not affect mouse pointer devices.

Defaults to 1.5 seconds (the tooltip is shown 1.5 seconds after a tap or long press is released).

See also:

  • dismiss_delay, which allows configuring the time until a pointer disappears when hovering.
§dismiss_delay: Duration

The length of time that a pointer must have stopped hovering over a tooltip’s widget before the tooltip will be hidden.

Defaults to 100 milliseconds.

See also:

  • touch_delay, which allows configuring the length of time that a tooltip will be visible after touch events are released.
§enable_tap_to_dismiss: bool

Whether the tooltip can be dismissed by tap.

The default value is true.

§trigger_mode: TooltipTriggerMode

The TooltipTriggerMode that will show the tooltip.

This property does not affect mouse devices. Setting trigger_mode to TooltipTriggerMode::Manual will not prevent the tooltip from showing when the mouse cursor hovers over it.

§enable_feedback: bool

Whether the tooltip should provide acoustic and/or haptic feedback.

For example, on Android a tap will produce a clicking sound and a long-press will produce a short vibration, when feedback is enabled.

When null, the default value is true.

See also:

  • Feedback, for providing platform-specific feedback to certain actions.
§on_triggered: Option<TooltipTriggeredCallback>

Called when the RawTooltip is triggered programmatically, on tap, or on long press.

The tooltip is triggered after a tap when trigger_mode is TooltipTriggerMode::Tap or after a long press when trigger_mode is TooltipTriggerMode::LongPress.

Hovering over the tooltip with a mouse pointer does not trigger this callback.

See also:

§animation_style: AnimationStyle

Used to override the curve and duration of the animation that shows and hides the tooltip.

If AnimationStyle::duration is provided, it will be used to override the show tooltip animation duration. If it is null, defaults to 150ms.

If AnimationStyle::curve is provided, it will be used to override the show tooltip animation curve. If it is null, defaults to Curves::fast_out_slow_in.

If AnimationStyle::reverse_duration is provided, it will be used to override the hide tooltip animation duration. If it is null, defaults to 75ms.

If AnimationStyle::reverse_curve is provided, it will be used to override the hide tooltip animation curve. If it is null, the same curve will be used as for the show tooltip animation. The reverse curve only takes effect when the tooltip starts hiding from the fully shown state; a tooltip dismissed while it is still animating in continues to use the show curve, to avoid a visual discontinuity. See CurvedAnimation::reverse_curve.

To disable the tooltip show/hide animation, use AnimationStyle::NO_ANIMATION.

§position_delegate: Option<TooltipPositionDelegate>

A custom position delegate function for computing where the tooltip should be positioned.

If provided, this function will be called with a TooltipPositionContext containing all the necessary information for positioning the tooltip. The function should return an Offset indicating where to place the tooltip in the closest Overlay.

This allows for custom positioning such as left/right positioning, or any other arbitrary positioning logic.

For example, if the Overlay takes up the entire screen, returning Offset::ZERO will position the tooltip at the top-left corner of the screen.

The TooltipPositionContext provides information that can be used to position the tooltip relative to the target/child.

If null, defaults to positioning the tooltip center-aligned and below the target using position_dependent_box.

See also:

§ignore_pointer: bool

Whether the tooltip should be invisible to hit testing.

Defaults to false.

See also:

  • IgnorePointer, for more information about how pointer events are handled or ignored.
§child: WidgetRef

The widget below this widget in the tree.

The widget returned in tooltip_builder will be shown when the user hovers over this child widget.

Implementations§

Source§

impl RawTooltip

Source

pub fn new<K>( semantics_tooltip: Option<String>, tooltip_builder: impl Fn(&mut App, BuildContext, AnimationRef<f64>) -> WidgetRef + 'static, child: impl IntoWidget<K>, ) -> RawTooltip

Creates a raw tooltip.

The semantics_tooltip, tooltip_builder, and child arguments are required.

Source

pub fn key(self, key: KeyRef) -> RawTooltip

Dart RawTooltip(key:).

Source

pub fn hover_delay(self, hover_delay: Duration) -> RawTooltip

Dart RawTooltip(hoverDelay:).

Source

pub fn touch_delay(self, touch_delay: Duration) -> RawTooltip

Dart RawTooltip(touchDelay:).

Source

pub fn dismiss_delay(self, dismiss_delay: Duration) -> RawTooltip

Dart RawTooltip(dismissDelay:).

Source

pub fn enable_tap_to_dismiss(self, enable_tap_to_dismiss: bool) -> RawTooltip

Dart RawTooltip(enableTapToDismiss:).

Source

pub fn trigger_mode(self, trigger_mode: TooltipTriggerMode) -> RawTooltip

Dart RawTooltip(triggerMode:).

Source

pub fn enable_feedback(self, enable_feedback: bool) -> RawTooltip

Dart RawTooltip(enableFeedback:).

Source

pub fn on_triggered(self, on_triggered: TooltipTriggeredCallback) -> RawTooltip

Dart RawTooltip(onTriggered:).

Source

pub fn animation_style(self, animation_style: AnimationStyle) -> RawTooltip

Dart RawTooltip(animationStyle:).

Source

pub fn position_delegate( self, position_delegate: TooltipPositionDelegate, ) -> RawTooltip

Dart RawTooltip(positionDelegate:).

Source

pub fn ignore_pointer(self, ignore_pointer: bool) -> RawTooltip

Dart RawTooltip(ignorePointer:).

Source

pub fn dismiss_all_tool_tips(app: &mut App) -> bool

Dismiss all of the tooltips that are currently shown on the screen, including those with mouse cursors currently hovering over them.

This method returns true if it successfully dismisses at least one tooltip and returns false if there is no tooltip currently displayed.

Trait Implementations§

Source§

impl Debug for RawTooltip

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl StatefulWidget for RawTooltip

Source§

type State = RawTooltipState

The state this widget creates.
Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s debugFillProperties: the properties a dump shows for this widget, in Dart’s order. Dart’s Widget base only sets the dense tree style, which the framework does.
Source§

fn create_state(&self) -> RawTooltipState

Creates the mutable state for this widget at a given location in the tree. Read more
Source§

fn debug_check_constructor(&self)

Source§

fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>

Source§

fn type_name(&self) -> &'static str

See Widget::type_name. A stateful form another widget kind becomes (an animated or status transition widget) names the widget it wraps.

Auto Trait Implementations§

§

impl !RefUnwindSafe for RawTooltip

§

impl !Send for RawTooltip

§

impl !Sync for RawTooltip

§

impl !UnwindSafe for RawTooltip

§

impl Forget for RawTooltip

§

impl Freeze for RawTooltip
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const RcInner<dyn Fn(&mut App, AnyElement, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>>>: Freeze, *const RcInner<dyn Fn(&mut App)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App)>>: Freeze, NonZero<u32>: Freeze, *const (): Freeze, *const RcInner<dyn Curve> is !null: Freeze, PhantomData<RcInner<dyn Curve>>: Freeze, *const RcInner<dyn Fn(TooltipPositionContext) -> Offset> is !null: Freeze, PhantomData<RcInner<dyn Fn(TooltipPositionContext) -> Offset>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze,

§

impl Move for RawTooltip

§

impl Unpin for RawTooltip
where Rc<dyn Key>: Unpin, *const u8 is !null: Unpin, Rc<dyn Fn(&mut App, AnyElement, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>>: Unpin, Rc<dyn Fn(&mut App)>: Unpin, NonZero<u32>: Unpin, *const (): Unpin, Rc<dyn Curve>: Unpin, Rc<dyn Fn(TooltipPositionContext) -> Offset>: Unpin, Rc<dyn Widget>: Unpin,

§

impl UnsafeUnpin for RawTooltip
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyElement, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App)>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, *const (): UnsafeUnpin, *const RcInner<dyn Curve> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Curve>>: UnsafeUnpin, *const RcInner<dyn Fn(TooltipPositionContext) -> Offset> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(TooltipPositionContext) -> Offset>>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<W> IntoWidget<StatefulKind> for W
where W: StatefulWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>