From b3e1a3ec662b7320054680eb732a1ed2f51fb170 Mon Sep 17 00:00:00 2001 From: Chloe <25387744+qimiko@users.noreply.github.com> Date: Wed, 25 Feb 2026 00:52:40 -0700 Subject: [PATCH 1/2] add popup/ime check in editor --- src/EditorUI.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/EditorUI.cpp b/src/EditorUI.cpp index ceddbcb..660bf16 100644 --- a/src/EditorUI.cpp +++ b/src/EditorUI.cpp @@ -310,7 +310,21 @@ struct $modify(EditorUI) { static inline bool s_allowPassThrough = false; + // popups are frequently in use, and we don't want keybinds to interfere with them + bool isTopLevel() { + if (CCIMEDispatcher::sharedDispatcher()->hasDelegate()) return false; + + if (auto handler = static_cast(CCKeyboardDispatcher::get()->m_pDelegates->lastObject())) { + // fix the pointer for comparison + return static_cast(this) == handler->m_pDelegate; + } + + return true; + } + void passThroughKeyDown(enumKeyCodes key, double timestamp, KeyboardModifier modifiers = KeyboardModifier::None) { + if (!isTopLevel()) return; + s_allowPassThrough = true; auto d = CCKeyboardDispatcher::get(); auto alt = d->m_bAltPressed; From 7567da0bf89f1e6aaaaa189f7b02e2667e583914 Mon Sep 17 00:00:00 2001 From: Chloe <25387744+qimiko@users.noreply.github.com> Date: Wed, 25 Feb 2026 01:08:08 -0700 Subject: [PATCH 2/2] fix propagate behavior --- src/EditorUI.cpp | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/EditorUI.cpp b/src/EditorUI.cpp index 660bf16..9f1d7da 100644 --- a/src/EditorUI.cpp +++ b/src/EditorUI.cpp @@ -273,10 +273,23 @@ struct $modify(EditorUI) { return EditorUI::moveObjectCall(p0); } + // popups are frequently in use, and we don't want keybinds to interfere with them + bool isTopLevel() { + if (CCIMEDispatcher::sharedDispatcher()->hasDelegate()) return false; + + if (auto handler = static_cast(CCKeyboardDispatcher::get()->m_pDelegates->lastObject())) { + // fix the pointer for comparison + return static_cast(this) == handler->m_pDelegate; + } + + return true; + } + void defineKeybind(std::string id, CopyableFunction callback) { this->addEventListener( KeybindSettingPressedEventV3(Mod::get(), std::move(id)), - [callback = std::move(callback)](Keybind const& keybind, bool down, bool repeat, double timestamp) { + [callback = std::move(callback), this](Keybind const& keybind, bool down, bool repeat, double timestamp) { + if (!isTopLevel()) return false; return callback(down, repeat, timestamp); } ); @@ -285,8 +298,10 @@ struct $modify(EditorUI) { void defineKeybind(std::string id, CopyableFunction callback) { this->addEventListener( KeybindSettingPressedEventV3(Mod::get(), std::move(id)), - [callback = std::move(callback)](Keybind const& keybind, bool down, bool repeat, double timestamp) { + [callback = std::move(callback), this](Keybind const& keybind, bool down, bool repeat, double timestamp) { if (down) { + if (!isTopLevel()) return ListenerResult::Propagate; + callback(repeat, timestamp); return ListenerResult::Stop; } @@ -298,8 +313,10 @@ struct $modify(EditorUI) { void defineKeybind(std::string id, CopyableFunction callback) { this->addEventListener( KeybindSettingPressedEventV3(Mod::get(), std::move(id)), - [callback = std::move(callback)](Keybind const& keybind, bool down, bool repeat, double timestamp) { + [callback = std::move(callback), this](Keybind const& keybind, bool down, bool repeat, double timestamp) { if (!repeat && down) { + if (!isTopLevel()) return ListenerResult::Propagate; + callback(timestamp); return ListenerResult::Stop; } @@ -310,21 +327,7 @@ struct $modify(EditorUI) { static inline bool s_allowPassThrough = false; - // popups are frequently in use, and we don't want keybinds to interfere with them - bool isTopLevel() { - if (CCIMEDispatcher::sharedDispatcher()->hasDelegate()) return false; - - if (auto handler = static_cast(CCKeyboardDispatcher::get()->m_pDelegates->lastObject())) { - // fix the pointer for comparison - return static_cast(this) == handler->m_pDelegate; - } - - return true; - } - void passThroughKeyDown(enumKeyCodes key, double timestamp, KeyboardModifier modifiers = KeyboardModifier::None) { - if (!isTopLevel()) return; - s_allowPassThrough = true; auto d = CCKeyboardDispatcher::get(); auto alt = d->m_bAltPressed;