feat: support pre-edit text display for IME (#35535)

* feat: support pre-edit text display for IME

Signed-off-by: DK Liao <dklassic@gmail.com>

* enable ime by show_ime

Signed-off-by: DK Liao <dklassic@gmail.com>

---------

Signed-off-by: DK Liao <dklassic@gmail.com>
This commit is contained in:
DK Liao 2025-02-19 20:22:57 +09:00 committed by GitHub
parent 42e873e9d9
commit 720bc725b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 91 additions and 4 deletions

View file

@ -988,6 +988,17 @@ impl<T: ClipboardProvider> TextInput<T> {
KeyReaction::DispatchInput
}
pub(crate) fn handle_compositionupdate(&mut self, event: &CompositionEvent) -> KeyReaction {
let start = self.selection_start_offset().0;
self.insert_string(event.data());
self.set_selection_range(
start as u32,
(start + event.data().len_utf8().0) as u32,
SelectionDirection::Forward,
);
KeyReaction::DispatchInput
}
/// Whether the content is empty.
pub(crate) fn is_empty(&self) -> bool {
self.lines.len() <= 1 && self.lines.first().map_or(true, |line| line.is_empty())