Trait rat_widget::event::HandleEvent
source · pub trait HandleEvent<Event, Qualifier, R>where
R: ConsumedEvent,{
// Required method
fn handle(&mut self, event: &Event, qualifier: Qualifier) -> R;
}Expand description
A very broad trait for an event handler.
Ratatui widgets have two separate structs, one that implements Widget/StatefulWidget and the associated State. As the StatefulWidget has a lifetime and is not meant to be kept, HandleEvent should be implemented for the state struct. It can then modify some state and the tui can be rendered anew with that changed state.
HandleEvent is not limited to State structs of course, any Type that wants to interact with events can implement it.
-
Event - The actual event type.
-
Qualifier - The qualifier allows creating more than one event-handler for a widget.
This can be used as a variant of type-state, where the type given selects the widget’s behaviour, or to give some external context to the widget, or to write your own key-bindings for a widget.
-
R - Result of event-handling. This can give information to the application what changed due to handling the event. This can be very specific for each widget, but there is one general Outcome that describes a minimal set of results.
There should be one value that indicates ‘I don’t know this event’. This is expressed with the ConsumedEvent trait.
Required Methods§
Implementations on Foreign Types§
source§impl HandleEvent<Event, Regular, CalOutcome> for &mut [MonthState]
impl HandleEvent<Event, Regular, CalOutcome> for &mut [MonthState]
source§impl<E, Q> HandleEvent<E, Q, Outcome> for ()
impl<E, Q> HandleEvent<E, Q, Outcome> for ()
Catch all event-handler for the null state ().
Implementors§
impl HandleEvent<Event, Dialog, Outcome> for MsgDialogState
impl HandleEvent<Event, Dialog, Result<FileOutcome, Error>> for FileDialogState
impl HandleEvent<Event, MouseOnly, ButtonOutcome> for ButtonState
impl HandleEvent<Event, MouseOnly, MenuOutcome> for MenuBarState
impl HandleEvent<Event, MouseOnly, MenuOutcome> for MenuLineState
impl HandleEvent<Event, MouseOnly, MenuOutcome> for PopupMenuState
impl HandleEvent<Event, MouseOnly, CalOutcome> for MonthState
impl HandleEvent<Event, MouseOnly, Outcome> for Focus
impl HandleEvent<Event, MouseOnly, Outcome> for ListState<NoSelection>
impl HandleEvent<Event, MouseOnly, Outcome> for ListState<RowSelection>
impl HandleEvent<Event, MouseOnly, Outcome> for ListState<RowSetSelection>
impl HandleEvent<Event, MouseOnly, Outcome> for ParagraphState
impl HandleEvent<Event, MouseOnly, Outcome> for SplitState
impl HandleEvent<Event, MouseOnly, Outcome> for TableState<CellSelection>
impl HandleEvent<Event, MouseOnly, Outcome> for TableState<NoSelection>
impl HandleEvent<Event, MouseOnly, Outcome> for TableState<RowSelection>
impl HandleEvent<Event, MouseOnly, Outcome> for TableState<RowSetSelection>
impl HandleEvent<Event, MouseOnly, Outcome> for ViewState
impl HandleEvent<Event, MouseOnly, ScrollOutcome> for ScrollState
impl HandleEvent<Event, MouseOnly, TabbedOutcome> for TabbedState
impl HandleEvent<Event, MouseOnly, TextOutcome> for DateInputState
impl HandleEvent<Event, MouseOnly, TextOutcome> for NumberInputState
impl HandleEvent<Event, MouseOnly, TextOutcome> for TextInputState
impl HandleEvent<Event, MouseOnly, TextOutcome> for MaskedInputState
impl HandleEvent<Event, MouseOnly, TextOutcome> for TextAreaState
impl HandleEvent<Event, Popup, MenuOutcome> for MenuBarState
impl HandleEvent<Event, Popup, MenuOutcome> for PopupMenuState
impl HandleEvent<Event, ReadOnly, TextOutcome> for DateInputState
impl HandleEvent<Event, ReadOnly, TextOutcome> for NumberInputState
impl HandleEvent<Event, ReadOnly, TextOutcome> for TextInputState
impl HandleEvent<Event, ReadOnly, TextOutcome> for MaskedInputState
impl HandleEvent<Event, ReadOnly, TextOutcome> for TextAreaState
impl HandleEvent<Event, Regular, ButtonOutcome> for ButtonState
impl HandleEvent<Event, Regular, MenuOutcome> for MenuBarState
impl HandleEvent<Event, Regular, MenuOutcome> for MenuLineState
impl HandleEvent<Event, Regular, CalOutcome> for MonthState
impl HandleEvent<Event, Regular, Outcome> for Focus
impl HandleEvent<Event, Regular, Outcome> for ListState<NoSelection>
impl HandleEvent<Event, Regular, Outcome> for ListState<RowSelection>
impl HandleEvent<Event, Regular, Outcome> for ListState<RowSetSelection>
impl HandleEvent<Event, Regular, Outcome> for ParagraphState
impl HandleEvent<Event, Regular, Outcome> for SplitState
impl HandleEvent<Event, Regular, Outcome> for TableState<CellSelection>
impl HandleEvent<Event, Regular, Outcome> for TableState<NoSelection>
impl HandleEvent<Event, Regular, Outcome> for TableState<RowSelection>
impl HandleEvent<Event, Regular, Outcome> for TableState<RowSetSelection>
impl HandleEvent<Event, Regular, TabbedOutcome> for TabbedState
Handle the regular events for Tabbed.
impl HandleEvent<Event, Regular, TextOutcome> for DateInputState
impl HandleEvent<Event, Regular, TextOutcome> for NumberInputState
impl HandleEvent<Event, Regular, TextOutcome> for TextInputState
impl HandleEvent<Event, Regular, TextOutcome> for MaskedInputState
impl HandleEvent<Event, Regular, TextOutcome> for TextAreaState
impl<'a> HandleEvent<Event, MouseOnly, ScrollOutcome> for ScrollAreaState<'a>
Handle scrolling for the whole area spanned by the two scroll-states.