Skip to main content

ferroui_controls/
text_changing_event_args.rs

1use ferroui_base::ferro_routed_event_args;
2use ferroui_base::interactivity::{RoutedEvent, RoutedEventArgs};
3use ferroui_base::{FerroObject, Nullable};
4
5/// Provides data specific to a `TextBox::text_changing` event.
6#[derive(Clone, Default)]
7pub struct TextChangingEventArgs {
8    base: RoutedEventArgs,
9}
10
11ferro_routed_event_args!(TextChangingEventArgs: RoutedEventArgs);
12
13impl TextChangingEventArgs {
14    /// Initializes a new instance of the `TextChangingEventArgs` class.
15    ///
16    /// `routed_event` is the routed event associated with these event args.
17    pub fn with_event<T: ?Sized>(routed_event: &RoutedEvent<T>) -> Self {
18        Self { base: RoutedEventArgs::with_event(routed_event) }
19    }
20
21    /// Initializes a new instance of the `TextChangingEventArgs` class.
22    ///
23    /// `routed_event` is the routed event associated with these event args,
24    /// `source` the source object that raised the routed event.
25    pub fn with_event_and_source<T: ?Sized>(
26        routed_event: &RoutedEvent<T>,
27        source: impl Into<Nullable<FerroObject>>,
28    ) -> Self {
29        Self { base: RoutedEventArgs::with_event_and_source(routed_event, source) }
30    }
31}