pub enum WidgetEvent {
None,
Selected {
path: Vec<usize>,
},
Toggled {
path: Vec<usize>,
expanded: bool,
},
Scrolled {
offset: usize,
direction: i32,
},
FilterModeChanged {
active: bool,
filter: String,
},
FilterModeExited {
path: Vec<usize>,
},
MenuSelected {
index: usize,
action: Option<Box<dyn FnOnce() + Send>>,
},
}Expand description
Common events emitted by interactive widgets.
This enum provides a standardized way for widgets to communicate actions to the parent application, reducing boilerplate in event handling loops.
§Example
use crate::primitives::widget_event::WidgetEvent;
fn handle_widget_event(event: WidgetEvent) {
match event {
WidgetEvent::None => {}
WidgetEvent::Selected { path } => println!("Selected: {:?}", path),
WidgetEvent::Toggled { path, expanded } => println!("Toggled: {:?} = {}", path, expanded),
WidgetEvent::Scrolled { offset, direction } => println!("Scrolled to {}", offset),
WidgetEvent::FilterModeChanged { active, filter } => {
println!("Filter {}: {}", if active { "on" } else { "off" }, filter);
}
WidgetEvent::FilterModeExited { path } => println!("Filter exited, focus: {:?}", path),
WidgetEvent::MenuSelected { index, action: _ } => println!("Menu item {} selected", index),
}
}Variants§
None
No event occurred.
Selected
A node/item was selected.
Toggled
An expandable item was toggled (expanded/collapsed).
Fields
Scrolled
Content was scrolled.
Fields
FilterModeChanged
Filter mode changed (entered, text changed, or exited with Esc).
FilterModeExited
Filter mode exited via Enter (focuses the selected item).
MenuSelected
A menu item was selected.
Trait Implementations§
Source§impl Debug for WidgetEvent
impl Debug for WidgetEvent
Source§impl Default for WidgetEvent
impl Default for WidgetEvent
Source§fn default() -> WidgetEvent
fn default() -> WidgetEvent
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for WidgetEvent
impl !RefUnwindSafe for WidgetEvent
impl Send for WidgetEvent
impl !Sync for WidgetEvent
impl Unpin for WidgetEvent
impl UnsafeUnpin for WidgetEvent
impl !UnwindSafe for WidgetEvent
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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