pub struct Tooltip {Show 24 fields
pub key: Option<KeyRef>,
pub message: Option<String>,
pub rich_message: Option<InlineSpanRef>,
pub height: Option<f64>,
pub constraints: Option<BoxConstraints>,
pub padding: Option<EdgeInsetsGeometry>,
pub margin: Option<EdgeInsetsGeometry>,
pub vertical_offset: Option<f64>,
pub prefer_below: Option<bool>,
pub exclude_from_semantics: Option<bool>,
pub child: Option<WidgetRef>,
pub decoration: Option<DecorationRef>,
pub text_style: Option<TextStyle>,
pub text_align: Option<TextAlign>,
pub wait_duration: Option<Duration>,
pub show_duration: Option<Duration>,
pub exit_duration: Option<Duration>,
pub enable_tap_to_dismiss: bool,
pub trigger_mode: Option<TooltipTriggerMode>,
pub enable_feedback: Option<bool>,
pub on_triggered: Option<TooltipTriggeredCallback>,
pub mouse_cursor: Option<MouseCursorRef>,
pub ignore_pointer: Option<bool>,
pub position_delegate: Option<TooltipPositionDelegate>,
}Expand description
A Material Design tooltip.
Tooltips provide text labels which help explain the function of a button or
other user interface action. Wrap the button in a Tooltip widget and provide
a message which will be shown when the widget is long pressed.
Many widgets, such as IconButton, FloatingActionButton, and
PopupMenuButton have a tooltip property that, when non-null, causes the
widget to include a Tooltip in its build.
Tooltips improve the accessibility of visual widgets by proving a textual representation of the widget, which, for example, can be vocalized by a screen reader.
This tooltip will default to showing above its child instead of below when its ambient
TooltipThemeData::prefer_below is false. Setting that piece of theme data is
recommended to avoid having a finger or cursor hide the tooltip. For other ways to set
that piece of theme data see:
Theme::data,ThemeData::tooltip_themeTooltipTheme::data
or it can be set directly on each tooltip with Tooltip::prefer_below.
A tooltip can be shown manually with TooltipTriggerMode::Manual by calling the
TooltipState::ensure_tooltip_visible function.
See also:
- https://material.io/design/components/tooltips.html
TooltipThemeorThemeData::tooltip_themeTooltipVisibility
Fields§
§key: Option<KeyRef>§message: Option<String>The text to display in the tooltip.
Only one of message and rich_message may be
non-null.
rich_message: Option<InlineSpanRef>The rich text to display in the tooltip.
Only one of message and rich_message may be
non-null.
height: Option<f64>Use Tooltip.constraints instead. This feature was deprecated after v3.30.0-0.1.pre.
The minimum height of the Tooltip’s message.
constraints: Option<BoxConstraints>Constrains the size of the Tooltip’s message.
If null, then the TooltipThemeData::constraints of the ambient
ThemeData::tooltip_theme will be used. If that is also null, then a default value
will be picked based on the current platform. For desktop platforms, the default value
is BoxConstraints(minHeight: 24.0), while for mobile platforms the default value is
BoxConstraints(minHeight: 32.0).
padding: Option<EdgeInsetsGeometry>The amount of space by which to inset the Tooltip’s message.
On mobile, defaults to 16.0 logical pixels horizontally and 4.0 vertically. On desktop, defaults to 8.0 logical pixels horizontally and 4.0 vertically.
margin: Option<EdgeInsetsGeometry>The empty space that surrounds the tooltip.
Defines the tooltip’s outer Container::margin. By default, a
long tooltip will span the width of its window. If long enough,
a tooltip might also span the window’s height. This property allows
one to define how much space the tooltip must be inset from the edges
of their display window.
If this property is null, then TooltipThemeData::margin is used.
If TooltipThemeData::margin is also null, the default margin is
0.0 logical pixels on all sides.
See also:
constraints, which allow setting an explicit size for the tooltip.
vertical_offset: Option<f64>The vertical gap between the widget and the displayed tooltip.
When prefer_below is set to true and tooltips have sufficient
space to display themselves, this property defines how much vertical space
tooltips will position themselves under their corresponding widgets.
Otherwise, tooltips will position themselves above their corresponding
widgets with the given offset.
prefer_below: Option<bool>Whether the tooltip defaults to being displayed below the widget.
If there is insufficient space to display the tooltip in the preferred direction, the tooltip will be displayed in the opposite direction.
If this property is null, then TooltipThemeData::prefer_below is used.
If that is also null, the default value is true.
Applying TooltipThemeData::prefer_below: false for the entire app
is recommended to avoid having a finger or cursor hide a tooltip.
exclude_from_semantics: Option<bool>Whether the tooltip’s message or
rich_message should be excluded from the semantics tree.
Defaults to false. A tooltip will add a Semantics label that is set to
Tooltip::message if non-null, or the plain text value of
Tooltip::rich_message otherwise. Set this property to true if the app is
going to provide its own custom semantics label.
child: Option<WidgetRef>The widget below this widget in the tree.
decoration: Option<DecorationRef>Specifies the tooltip’s shape and background color.
The tooltip shape defaults to a rounded rectangle with a border radius of
4.0. Tooltips will also default to an opacity of 90% and with the color
Colors::GREY[700] if ThemeData::brightness is Brightness::Light, and
Colors::WHITE if it is Brightness::Dark.
text_style: Option<TextStyle>The style to use for the message of the tooltip.
If null, the message’s TextStyle will be determined based on
ThemeData. If ThemeData::brightness is set to Brightness::Dark,
TextTheme::body_medium of ThemeData::text_theme will be used with
Colors::WHITE. Otherwise, if ThemeData::brightness is set to
Brightness::Light, TextTheme::body_medium of ThemeData::text_theme will be
used with Colors::BLACK.
text_align: Option<TextAlign>How the message of the tooltip is aligned horizontally.
If this property is null, then TooltipThemeData::text_align is used.
If TooltipThemeData::text_align is also null, the default value is
TextAlign::Start.
wait_duration: Option<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).
show_duration: Option<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:
exit_duration, which allows configuring the time until a pointer disappears when hovering.
exit_duration: Option<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:
show_duration, which allows configuring the length of time that a tooltip will be visible after touch events are released.
enable_tap_to_dismiss: boolWhether the tooltip can be dismissed by tap.
The default value is true.
trigger_mode: Option<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.
If this property is null, then TooltipThemeData::trigger_mode is used.
If TooltipThemeData::trigger_mode is also null, the default mode is
TooltipTriggerMode::LongPress.
enable_feedback: Option<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 Tooltip 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.
mouse_cursor: Option<MouseCursorRef>The cursor for a mouse pointer when it enters or is hovering over the widget.
If this property is null, MouseCursor::defer will be used.
ignore_pointer: Option<bool>Whether this tooltip should be invisible to hit testing.
If no value is passed, pointer events are ignored unless the tooltip has a
rich_message instead of a message.
See also:
IgnorePointer, for more information about how pointer events are handled or ignored.
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.
If null, defaults to positioning the tooltip center-aligned and below the
target using position_dependent_box.
Implementations§
Source§impl Tooltip
impl Tooltip
Sourcepub fn new() -> Tooltip
pub fn new() -> Tooltip
Creates a tooltip.
By default, tooltips should adhere to the
Material specification.
If the optional constructor parameters are not defined, the values
provided by TooltipTheme::of will be used if a TooltipTheme is present
or specified in ThemeData.
All parameters that are defined in the constructor will
override the default values and the values in TooltipTheme::of.
Exactly one of message and rich_message must
be given; the tooltip’s state checks it when it builds.
Sourcepub fn rich_message(self, rich_message: InlineSpanRef) -> Tooltip
pub fn rich_message(self, rich_message: InlineSpanRef) -> Tooltip
Dart Tooltip(richMessage:).
Sourcepub fn height(self, height: f64) -> Tooltip
👎Deprecated: Use Tooltip.constraints instead. This feature was deprecated after v3.30.0-0.1.pre.
pub fn height(self, height: f64) -> Tooltip
Use Tooltip.constraints instead. This feature was deprecated after v3.30.0-0.1.pre.
Dart Tooltip(height:).
Sourcepub fn constraints(self, constraints: BoxConstraints) -> Tooltip
pub fn constraints(self, constraints: BoxConstraints) -> Tooltip
Dart Tooltip(constraints:).
Sourcepub fn padding(self, padding: impl Into<EdgeInsetsGeometry>) -> Tooltip
pub fn padding(self, padding: impl Into<EdgeInsetsGeometry>) -> Tooltip
Dart Tooltip(padding:).
Sourcepub fn margin(self, margin: impl Into<EdgeInsetsGeometry>) -> Tooltip
pub fn margin(self, margin: impl Into<EdgeInsetsGeometry>) -> Tooltip
Dart Tooltip(margin:).
Sourcepub fn vertical_offset(self, vertical_offset: f64) -> Tooltip
pub fn vertical_offset(self, vertical_offset: f64) -> Tooltip
Dart Tooltip(verticalOffset:).
Sourcepub fn prefer_below(self, prefer_below: bool) -> Tooltip
pub fn prefer_below(self, prefer_below: bool) -> Tooltip
Dart Tooltip(preferBelow:).
Sourcepub fn exclude_from_semantics(self, exclude_from_semantics: bool) -> Tooltip
pub fn exclude_from_semantics(self, exclude_from_semantics: bool) -> Tooltip
Dart Tooltip(excludeFromSemantics:).
Sourcepub fn decoration(self, decoration: impl Into<DecorationRef>) -> Tooltip
pub fn decoration(self, decoration: impl Into<DecorationRef>) -> Tooltip
Dart Tooltip(decoration:).
Sourcepub fn text_style(self, text_style: TextStyle) -> Tooltip
pub fn text_style(self, text_style: TextStyle) -> Tooltip
Dart Tooltip(textStyle:).
Sourcepub fn text_align(self, text_align: TextAlign) -> Tooltip
pub fn text_align(self, text_align: TextAlign) -> Tooltip
Dart Tooltip(textAlign:).
Sourcepub fn wait_duration(self, wait_duration: Duration) -> Tooltip
pub fn wait_duration(self, wait_duration: Duration) -> Tooltip
Dart Tooltip(waitDuration:).
Sourcepub fn show_duration(self, show_duration: Duration) -> Tooltip
pub fn show_duration(self, show_duration: Duration) -> Tooltip
Dart Tooltip(showDuration:).
Sourcepub fn exit_duration(self, exit_duration: Duration) -> Tooltip
pub fn exit_duration(self, exit_duration: Duration) -> Tooltip
Dart Tooltip(exitDuration:).
Sourcepub fn enable_tap_to_dismiss(self, enable_tap_to_dismiss: bool) -> Tooltip
pub fn enable_tap_to_dismiss(self, enable_tap_to_dismiss: bool) -> Tooltip
Dart Tooltip(enableTapToDismiss:).
Sourcepub fn trigger_mode(self, trigger_mode: TooltipTriggerMode) -> Tooltip
pub fn trigger_mode(self, trigger_mode: TooltipTriggerMode) -> Tooltip
Dart Tooltip(triggerMode:).
Sourcepub fn enable_feedback(self, enable_feedback: bool) -> Tooltip
pub fn enable_feedback(self, enable_feedback: bool) -> Tooltip
Dart Tooltip(enableFeedback:).
Sourcepub fn on_triggered(self, on_triggered: TooltipTriggeredCallback) -> Tooltip
pub fn on_triggered(self, on_triggered: TooltipTriggeredCallback) -> Tooltip
Dart Tooltip(onTriggered:).
Sourcepub fn mouse_cursor(self, mouse_cursor: MouseCursorRef) -> Tooltip
pub fn mouse_cursor(self, mouse_cursor: MouseCursorRef) -> Tooltip
Dart Tooltip(mouseCursor:).
Sourcepub fn ignore_pointer(self, ignore_pointer: bool) -> Tooltip
pub fn ignore_pointer(self, ignore_pointer: bool) -> Tooltip
Dart Tooltip(ignorePointer:).
Sourcepub fn position_delegate(
self,
position_delegate: TooltipPositionDelegate,
) -> Tooltip
pub fn position_delegate( self, position_delegate: TooltipPositionDelegate, ) -> Tooltip
Dart Tooltip(positionDelegate:).
Sourcepub fn child<K>(self, child: impl IntoWidget<K>) -> Tooltip
pub fn child<K>(self, child: impl IntoWidget<K>) -> Tooltip
Dart Tooltip(child:).
Sourcepub fn dismiss_all_tool_tips(app: &mut App) -> bool
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 StatefulWidget for Tooltip
impl StatefulWidget for Tooltip
Source§type State = TooltipState
type State = TooltipState
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
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) -> TooltipState
fn create_state(&self) -> TooltipState
Source§fn as_preferred_size_widget(
&self,
) -> Option<&(dyn PreferredSizeWidget + 'static)>
fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
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 Tooltip
impl !Send for Tooltip
impl !Sync for Tooltip
impl !UnwindSafe for Tooltip
impl Forget for Tooltip
impl Freeze for Tooltipwhere
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const RcInner<dyn InlineSpan> is !null: Freeze,
PhantomData<RcInner<dyn InlineSpan>>: Freeze,
*const RcInner<dyn Widget> is !null: Freeze,
PhantomData<RcInner<dyn Widget>>: Freeze,
*const RcInner<dyn Decoration> is !null: Freeze,
PhantomData<RcInner<dyn Decoration>>: Freeze,
&'static dyn ColorExtension: Freeze,
*const RcInner<dyn ColorExtension> is !null: Freeze,
PhantomData<RcInner<dyn ColorExtension>>: Freeze,
PhantomData<String>: Freeze,
*const RcInner<Paint> is !null: Freeze,
PhantomData<RcInner<Paint>>: Freeze,
PhantomData<Shadow>: Freeze,
PhantomData<FontFeature>: Freeze,
PhantomData<FontVariation>: 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 MouseCursor> is !null: Freeze,
PhantomData<RcInner<dyn MouseCursor>>: Freeze,
*const RcInner<dyn Fn(TooltipPositionContext) -> Offset> is !null: Freeze,
PhantomData<RcInner<dyn Fn(TooltipPositionContext) -> Offset>>: Freeze,
impl Move for Tooltip
impl Unpin for Tooltipwhere
Rc<dyn Key>: Unpin,
*const u8 is !null: Unpin,
Rc<dyn InlineSpan>: Unpin,
Rc<dyn Widget>: Unpin,
Rc<dyn Decoration>: Unpin,
&'static dyn ColorExtension: Unpin,
Rc<dyn ColorExtension>: Unpin,
Rc<Paint>: Unpin,
Rc<dyn Fn(&mut App)>: Unpin,
NonZero<u32>: Unpin,
*const (): Unpin,
Rc<dyn MouseCursor>: Unpin,
Rc<dyn Fn(TooltipPositionContext) -> Offset>: Unpin,
impl UnsafeUnpin for Tooltipwhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const RcInner<dyn InlineSpan> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn InlineSpan>>: UnsafeUnpin,
*const RcInner<dyn Widget> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,
*const RcInner<dyn Decoration> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Decoration>>: UnsafeUnpin,
&'static dyn ColorExtension: UnsafeUnpin,
*const RcInner<dyn ColorExtension> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn ColorExtension>>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const RcInner<Paint> is !null: UnsafeUnpin,
PhantomData<RcInner<Paint>>: UnsafeUnpin,
PhantomData<Shadow>: UnsafeUnpin,
PhantomData<FontFeature>: UnsafeUnpin,
PhantomData<FontVariation>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App)>>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
*const (): UnsafeUnpin,
*const RcInner<dyn MouseCursor> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn MouseCursor>>: UnsafeUnpin,
*const RcInner<dyn Fn(TooltipPositionContext) -> Offset> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(TooltipPositionContext) -> Offset>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.