pub struct IconButton<Msg> { /* private fields */ }Expand description
A button that is one icon: a space, the glyph and a space, three cells in every glyph mode.
It stands on the ground around it, with no raised surface, so a row of them reads as quiet
marks rather than as buttons with labels. The pointer lightens all three cells, keyboard focus
lightens them one step further, and a press flashes them one step more; there is no pillar,
because three cells have no room for one before the glyph. Enter or Space while focused, or a
click released over it, sends its message, like a Button.
Its meaning is only the glyph, so give it a tooltip: the words show below it
after the pointer rests on it for the theme’s hover delay, and at once when it is reached with
the keyboard.
Style keys: icon-button (fg, bg, bold) with states hover, focus, pressed and
disabled; tooltip for its words.
use qframe::prelude::*;
use qframe::widgets::IconButton;
struct Header;
impl App for Header {
type Msg = ();
fn update(&mut self, (): ()) -> Command<()> {
Command::none()
}
fn view(&self, ui: &mut View<'_, ()>) {
ui.row(|ui| {
ui.add(Text::new("Packages")).fill_width();
ui.add(IconButton::new("settings").tooltip("Settings").on_press(()));
})
.fill_width();
}
}
let app = Harness::new(Header, 20, 1);
let glyph = app.env().icons().glyph("settings").into_owned();
assert_eq!(app.find(&glyph), Some((18, 0)), "a space, the glyph and a space at the end");Implementations§
Source§impl<Msg> IconButton<Msg>
impl<Msg> IconButton<Msg>
Sourcepub fn new(key: impl Into<String>) -> Self
pub fn new(key: impl Into<String>) -> Self
A button showing the icon key of the icon set, such as "settings" or "close".
Trait Implementations§
Source§impl<Msg: Clone + 'static> Widget<Msg> for IconButton<Msg>
impl<Msg: Clone + 'static> Widget<Msg> for IconButton<Msg>
Source§fn measure(&self, cx: &mut MeasureCx<'_>, available: Size) -> Size
fn measure(&self, cx: &mut MeasureCx<'_>, available: Size) -> Size
available.Source§fn paint_overlay(&self, cx: &mut PaintCx<'_>, anchor: Rect)
fn paint_overlay(&self, cx: &mut PaintCx<'_>, anchor: Rect)
PaintCx::request_overlay. anchor is the area the widget was painted in.Source§fn event(&self, cx: &mut EventCx<'_, Msg>, event: &Event) -> bool
fn event(&self, cx: &mut EventCx<'_, Msg>, event: &Event) -> bool
true when the event was used; unused key and scroll events
bubble to the parent widget.Source§fn children_mut(&mut self) -> &mut [Node<Msg>]
fn children_mut(&mut self) -> &mut [Node<Msg>]
Auto Trait Implementations§
impl<Msg> Freeze for IconButton<Msg>
impl<Msg> RefUnwindSafe for IconButton<Msg>where
Option<Msg>: RefUnwindSafe,
impl<Msg> Send for IconButton<Msg>
impl<Msg> Sync for IconButton<Msg>
impl<Msg> Unpin for IconButton<Msg>
impl<Msg> UnsafeUnpin for IconButton<Msg>where
Option<Msg>: UnsafeUnpin,
impl<Msg> UnwindSafe for IconButton<Msg>where
Option<Msg>: UnwindSafe,
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
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> ⓘ
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> ⓘ
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