From 8e4ef926691e3efba5daff34b8c1b77bf528d45a Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Sat, 13 May 2023 03:02:05 +0300 Subject: [PATCH] On macOS, fix backspace emission on preedit clear Fixes: d15feb5cfa (On macOS, fix empty marked text) --- CHANGELOG.md | 3 +++ src/platform_impl/macos/view.rs | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e93b23da9..dbe142335d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ And please only add new entries to the top of this list, right below the `# Unre # Unreleased +- On macOS, fixed memory leak when getting monitor handle. +- On macOS, fix `Backspace` being emitted when clearing preedit with it. + # 0.28.5 - On macOS, fix `key_up` beind ignored when `Ime` is disabled. diff --git a/src/platform_impl/macos/view.rs b/src/platform_impl/macos/view.rs index ef03dd7a33..cacbf10e8c 100644 --- a/src/platform_impl/macos/view.rs +++ b/src/platform_impl/macos/view.rs @@ -50,7 +50,7 @@ impl Default for CursorState { } } -#[derive(Debug, Eq, PartialEq)] +#[derive(Debug, Eq, PartialEq, Clone, Copy)] enum ImeState { /// The IME events are disabled, so only `ReceivedCharacter` is being sent to the user. Disabled, @@ -481,6 +481,7 @@ declare_class!( && !ev_mods.logo(); let characters = get_characters(event, ignore_alt_characters); + let old_ime_state = self.state.ime_state; self.state.forward_key_to_app = false; // The `interpretKeyEvents` function might call @@ -518,7 +519,8 @@ declare_class!( true } ImeState::Preedit => true, - _ => false, + // `key_down` could result in preedit clear, so compare old and current state. + _ => old_ime_state != self.state.ime_state, }; if !had_ime_input || self.state.forward_key_to_app {