From 720bc725b0c1cd5f01f9ff1d17793a3b1f32a480 Mon Sep 17 00:00:00 2001 From: DK Liao Date: Wed, 19 Feb 2025 20:22:57 +0900 Subject: feat: support pre-edit text display for IME (#35535) * feat: support pre-edit text display for IME Signed-off-by: DK Liao * enable ime by show_ime Signed-off-by: DK Liao --------- Signed-off-by: DK Liao --- components/script/textinput.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'components/script/textinput.rs') diff --git a/components/script/textinput.rs b/components/script/textinput.rs index 4406984a34f..1a72c0d26f8 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -988,6 +988,17 @@ impl TextInput { 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()) -- cgit v1.2.3