pub struct OnClick<W> { /* private fields */ }Expand description
Wraps a widget so a callback fires when it is clicked.
The wrapper renders the inner widget, then renders a companion button whose
label is click_label; when that button reports clicked, the callback
runs. This keeps the immediate-mode contract (no retained state) while still
offering an ergonomic .on_click combinator. Use OnClick::probe in
tests to drive the callback directly.
Implementations§
Source§impl<W: Widget> OnClick<W>
impl<W: Widget> OnClick<W>
Sourcepub fn probe(&mut self, response: &ButtonResponse) -> bool
pub fn probe(&mut self, response: &ButtonResponse) -> bool
Manually deliver a ButtonResponse; invokes the callback when
response.clicked is set. Returns whether the callback fired.
Trait Implementations§
Auto Trait Implementations§
impl<W> Freeze for OnClick<W>where
W: Freeze,
impl<W> !RefUnwindSafe for OnClick<W>
impl<W> !Send for OnClick<W>
impl<W> !Sync for OnClick<W>
impl<W> Unpin for OnClick<W>where
W: Unpin,
impl<W> UnsafeUnpin for OnClick<W>where
W: UnsafeUnpin,
impl<W> !UnwindSafe for OnClick<W>
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