#[non_exhaustive]pub enum ImeEvent {
Enabled,
Preedit {
preedit: ImePreedit,
pos: Option<Point>,
},
Commit {
text: String,
},
End,
Disabled,
}Expand description
Input Method Editor events for CJK and similar input.
Possible values cover enabled, preedit, commit, end, and disabled phases.
§Examples
use ailloli_ui_core::event::ImeEvent;
assert_eq!(ImeEvent::commit("文").committed_text(), Some("文"));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Enabled
The platform enabled text composition for the focused input.
Preedit
Composition started or updated.
Fields
preedit: ImePreeditCurrent validated composition payload.
Commit
Final committed text.
End
Composition ended or cleared.
Disabled
The platform disabled text composition for the focused input.
Implementations§
Source§impl ImeEvent
impl ImeEvent
Sourcepub const fn enabled() -> Self
pub const fn enabled() -> Self
Creates an IME-enabled notification.
§Examples
use ailloli_ui_core::event::ImeEvent;
assert!(matches!(ImeEvent::enabled(), ImeEvent::Enabled));Sourcepub const fn preedit(preedit: ImePreedit, pos: Option<Point>) -> Self
pub const fn preedit(preedit: ImePreedit, pos: Option<Point>) -> Self
Creates a preedit update from an already constructed payload.
This const constructor does not call ImePreedit::validate; use
Self::try_preedit for untrusted provider indices.
§Examples
use ailloli_ui_core::event::{ImeEvent, ImePreedit};
assert!(ImeEvent::preedit(ImePreedit::new("文"), None).as_preedit().is_some());Sourcepub fn try_preedit(
text: impl Into<String>,
selection: Option<(usize, usize)>,
pos: Option<Point>,
) -> Result<Self, ImePreeditError>
pub fn try_preedit( text: impl Into<String>, selection: Option<(usize, usize)>, pos: Option<Point>, ) -> Result<Self, ImePreeditError>
Validates and creates a preedit update from raw UTF-8 byte indices.
§Errors
Returns ImePreeditError for an invalid selection range.
§Examples
use ailloli_ui_core::event::ImeEvent;
let event = ImeEvent::try_preedit("é", Some((0, 2)), None)?;
assert_eq!(event.as_preedit().unwrap().0.text(), "é");Sourcepub fn commit(text: impl Into<String>) -> Self
pub fn commit(text: impl Into<String>) -> Self
Creates a committed-text event.
§Examples
use ailloli_ui_core::event::ImeEvent;
assert_eq!(ImeEvent::commit("文").committed_text(), Some("文"));Sourcepub const fn end() -> Self
pub const fn end() -> Self
Creates the legacy composition-end notification.
§Examples
use ailloli_ui_core::event::ImeEvent;
assert!(matches!(ImeEvent::end(), ImeEvent::End));Sourcepub const fn disabled() -> Self
pub const fn disabled() -> Self
Creates an IME-disabled notification.
§Examples
use ailloli_ui_core::event::ImeEvent;
assert!(matches!(ImeEvent::disabled(), ImeEvent::Disabled));Sourcepub const fn as_preedit(&self) -> Option<(&ImePreedit, Option<Point>)>
pub const fn as_preedit(&self) -> Option<(&ImePreedit, Option<Point>)>
Returns the preedit payload and provider position, when applicable.
§Examples
use ailloli_ui_core::{event::{ImeEvent, ImePreedit}, Point};
let event = ImeEvent::preedit(ImePreedit::new("文"), Some(Point::new(1.0, 2.0)));
assert_eq!(event.as_preedit().unwrap().1, Some(Point::new(1.0, 2.0)));Sourcepub fn committed_text(&self) -> Option<&str>
pub fn committed_text(&self) -> Option<&str>
Returns committed text when this is a commit event.
§Examples
use ailloli_ui_core::event::ImeEvent;
assert_eq!(ImeEvent::enabled().committed_text(), None);