Skip to content

Commit b3e1a3e

Browse files
committed
add popup/ime check in editor
1 parent b6e4766 commit b3e1a3e

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/EditorUI.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,21 @@ struct $modify(EditorUI) {
310310

311311
static inline bool s_allowPassThrough = false;
312312

313+
// popups are frequently in use, and we don't want keybinds to interfere with them
314+
bool isTopLevel() {
315+
if (CCIMEDispatcher::sharedDispatcher()->hasDelegate()) return false;
316+
317+
if (auto handler = static_cast<CCKeyboardHandler*>(CCKeyboardDispatcher::get()->m_pDelegates->lastObject())) {
318+
// fix the pointer for comparison
319+
return static_cast<CCKeyboardDelegate*>(this) == handler->m_pDelegate;
320+
}
321+
322+
return true;
323+
}
324+
313325
void passThroughKeyDown(enumKeyCodes key, double timestamp, KeyboardModifier modifiers = KeyboardModifier::None) {
326+
if (!isTopLevel()) return;
327+
314328
s_allowPassThrough = true;
315329
auto d = CCKeyboardDispatcher::get();
316330
auto alt = d->m_bAltPressed;

0 commit comments

Comments
 (0)