Skip to main content

ferroui_base/input/raw/
raw_text_input_event_args.rs

1use super::raw_input_event_args::raw_input_event_args;
2use super::RawInputEventArgs;
3use crate::input::{IInputDevice, IInputRoot};
4use std::rc::Rc;
5
6/// A raw text input event.
7pub struct RawTextInputEventArgs {
8    base: RawInputEventArgs,
9    text: String,
10}
11
12raw_input_event_args!(RawTextInputEventArgs: RawInputEventArgs);
13
14impl RawTextInputEventArgs {
15    /// Creates raw text input event args. `device` is the keyboard device
16    /// the text comes from.
17    pub fn new(device: Rc<dyn IInputDevice>, timestamp: u64, root: Rc<dyn IInputRoot>, text: impl Into<String>) -> Self {
18        Self { base: RawInputEventArgs::new(device, timestamp, root), text: text.into() }
19    }
20
21    /// The text that was input.
22    #[inline]
23    pub fn text(&self) -> &str {
24        &self.text
25    }
26}