diff options
author | DK Liao <dklassic@gmail.com> | 2025-02-19 20:22:57 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-19 11:22:57 +0000 |
commit | 720bc725b0c1cd5f01f9ff1d17793a3b1f32a480 (patch) | |
tree | 135e61279bc4b61bd769ce48e103d3b8e4498268 /components/script/textinput.rs | |
parent | 42e873e9d91ce145b871186b6ced9c064ef50020 (diff) | |
download | servo-720bc725b0c1cd5f01f9ff1d17793a3b1f32a480.tar.gz servo-720bc725b0c1cd5f01f9ff1d17793a3b1f32a480.zip |
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>
Diffstat (limited to 'components/script/textinput.rs')
-rw-r--r-- | components/script/textinput.rs | 11 |
1 files changed, 11 insertions, 0 deletions
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<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()) |