From af4a05c45d1ec12d942ff95655a03625ae301129 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Mon, 22 Apr 2024 20:30:13 +0900 Subject: [PATCH 1/4] Update state.rs --- crates/egui/src/widgets/text_edit/state.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/egui/src/widgets/text_edit/state.rs b/crates/egui/src/widgets/text_edit/state.rs index ef4a8909a73..735865d737b 100644 --- a/crates/egui/src/widgets/text_edit/state.rs +++ b/crates/egui/src/widgets/text_edit/state.rs @@ -44,6 +44,10 @@ pub struct TextEditState { #[cfg_attr(feature = "serde", serde(skip))] pub(crate) ime_enabled: bool, + // target ID for IME candidate. + #[cfg_attr(feature = "serde", serde(skip))] + pub(crate) ime_target_id: Id, + // cursor range for IME candidate. #[cfg_attr(feature = "serde", serde(skip))] pub(crate) ime_cursor_range: CursorRange, From a94b9eee31de678ced17db4259eadcac79645546 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Mon, 22 Apr 2024 20:32:31 +0900 Subject: [PATCH 2/4] Update builder.rs --- crates/egui/src/widgets/text_edit/builder.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs index c0b8532d6d9..7ab13e6eca5 100644 --- a/crates/egui/src/widgets/text_edit/builder.rs +++ b/crates/egui/src/widgets/text_edit/builder.rs @@ -953,6 +953,7 @@ fn events( Event::Ime(ime_event) => match ime_event { ImeEvent::Enabled => { state.ime_enabled = true; + state.ime_target_id = id; state.ime_cursor_range = cursor_range; None } @@ -978,6 +979,7 @@ fn events( state.ime_enabled = false; if !prediction.is_empty() + && state.ime_target_id == id && cursor_range.secondary.ccursor.index == state.ime_cursor_range.secondary.ccursor.index { From de2390327dc6489ffd136a8e01e7e068be1fc9b9 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Mon, 22 Apr 2024 20:34:08 +0900 Subject: [PATCH 3/4] Update id.rs --- crates/egui/src/id.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/egui/src/id.rs b/crates/egui/src/id.rs index 0465c32d76c..fd484968132 100644 --- a/crates/egui/src/id.rs +++ b/crates/egui/src/id.rs @@ -33,6 +33,12 @@ use std::num::NonZeroU64; #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct Id(NonZeroU64); +impl Default for Id { + fn default() -> Self { + Self::NULL + } +} + impl Id { /// A special [`Id`], in particular as a key to [`crate::Memory::data`] /// for when there is no particular widget to attach the data. From 2c9722da6561b737a003979cdab22f6961807830 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Tue, 23 Apr 2024 15:54:09 +0900 Subject: [PATCH 4/4] Update state.rs --- crates/egui/src/widgets/text_edit/state.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/egui/src/widgets/text_edit/state.rs b/crates/egui/src/widgets/text_edit/state.rs index 735865d737b..1ae2b80bd86 100644 --- a/crates/egui/src/widgets/text_edit/state.rs +++ b/crates/egui/src/widgets/text_edit/state.rs @@ -44,7 +44,7 @@ pub struct TextEditState { #[cfg_attr(feature = "serde", serde(skip))] pub(crate) ime_enabled: bool, - // target ID for IME candidate. + // target TextEdit ID for IME candidate. #[cfg_attr(feature = "serde", serde(skip))] pub(crate) ime_target_id: Id,