Skip to main content

ferroui_base/input/
text_input_event_args.rs

1use super::text_input::TextInputMethodCommit;
2use crate::ferro_routed_event_args;
3use crate::interactivity::RoutedEventArgs;
4use std::rc::Rc;
5
6/// Provides information specific to a text input event.
7#[derive(Clone, Default)]
8pub struct TextInputEventArgs {
9    base: RoutedEventArgs,
10    pub(crate) input_method_commit: Option<Rc<TextInputMethodCommit>>,
11
12    /// The text that was input.
13    pub text: Option<String>,
14}
15
16ferro_routed_event_args!(TextInputEventArgs: RoutedEventArgs);
17
18impl TextInputEventArgs {
19    /// The captured platform commit. A handling editor acknowledges its real result.
20    pub fn input_method_commit(&self) -> Option<&Rc<TextInputMethodCommit>> {
21        self.input_method_commit.as_ref()
22    }
23
24    /// Creates args with no text and no routed event.
25    pub fn new() -> Self {
26        Self::default()
27    }
28}