pub struct Tooltip<Msg> { /* private fields */ }Expand description
Wraps widgets and shows a short text next to them after the pointer rests on them for the
theme’s motion.hover-delay.
The text is one row on the overlay surface, below the widgets by default. It flips to the
other side when there is no room, and moves to another side when it would cover the pointer.
It disappears as soon as the pointer leaves. With on_focus it also
shows, at once, while keyboard focus is inside. The text fades in over motion.enter.
Style keys: tooltip (bg, fg, padding).
use qframe::prelude::*;
use qframe::widgets::Tooltip;
struct Toolbar;
impl App for Toolbar {
type Msg = ();
fn update(&mut self, (): ()) -> Command<()> {
Command::none()
}
fn view(&self, ui: &mut View<'_, ()>) {
ui.add_with(Tooltip::new("Restart every container"), |ui| {
ui.add(Button::new("Restart").on_press(()));
});
}
}
let mut app = Harness::new(Toolbar, 40, 4);
app.hover(3, 0).advance(std::time::Duration::from_secs(1));
assert!(app.screen().contains("Restart every container"));Implementations§
Trait Implementations§
Source§impl<Msg: 'static> Container<Msg> for Tooltip<Msg>
impl<Msg: 'static> Container<Msg> for Tooltip<Msg>
Source§fn set_children(&mut self, children: Vec<Node<Msg>>)
fn set_children(&mut self, children: Vec<Node<Msg>>)
Receives the children built for this widget.
Source§impl<Msg: 'static> Widget<Msg> for Tooltip<Msg>
impl<Msg: 'static> Widget<Msg> for Tooltip<Msg>
Source§fn measure(&self, cx: &mut MeasureCx<'_>, available: Size) -> Size
fn measure(&self, cx: &mut MeasureCx<'_>, available: Size) -> Size
The size the widget wants when it may use up to
available.Source§fn paint_overlay(&self, cx: &mut PaintCx<'_>, anchor: Rect)
fn paint_overlay(&self, cx: &mut PaintCx<'_>, anchor: Rect)
Draws the widget’s overlay after the whole view was painted, when it asked for one with
PaintCx::request_overlay. anchor is the area the widget was painted in.Source§fn children_mut(&mut self) -> &mut [Node<Msg>]
fn children_mut(&mut self) -> &mut [Node<Msg>]
Mutable child nodes, used to assign ids.
Auto Trait Implementations§
impl<Msg> !RefUnwindSafe for Tooltip<Msg>
impl<Msg> !Send for Tooltip<Msg>
impl<Msg> !Sync for Tooltip<Msg>
impl<Msg> !UnwindSafe for Tooltip<Msg>
impl<Msg> Freeze for Tooltip<Msg>
impl<Msg> Unpin for Tooltip<Msg>
impl<Msg> UnsafeUnpin for Tooltip<Msg>
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
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more