Introduce custom method to widget::Operation trait

This allows users to write operations for their custom widgets.
This commit is contained in:
Héctor Ramón Jiménez 2023-01-14 03:20:30 +01:00
parent 18552f96df
commit daa3f3324d
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
4 changed files with 24 additions and 0 deletions

View file

@ -9,6 +9,7 @@ pub use text_input::TextInput;
use crate::widget::Id;
use std::any::Any;
use std::fmt;
/// A piece of logic that can traverse the widget tree of an application in
@ -33,6 +34,9 @@ pub trait Operation<T> {
/// Operates on a widget that has text input.
fn text_input(&mut self, _state: &mut dyn TextInput, _id: Option<&Id>) {}
/// Operates on a custom widget with some state.
fn custom(&mut self, _state: &mut dyn Any, _id: Option<&Id>) {}
/// Finishes the [`Operation`] and returns its [`Outcome`].
fn finish(&self) -> Outcome<T> {
Outcome::None