From ae0c4d927a6a9d2cc19065c6e653da17403d7a2a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 6 Jan 2025 07:13:40 -0800 Subject: [PATCH] macos: halt NSEvent processing at app scope only if event is handled Fixes #4677 --- macos/Sources/App/macOS/AppDelegate.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index 1a23eca90..e3518cd2b 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -430,8 +430,15 @@ class AppDelegate: NSObject, ghostty_app_key_is_binding( app, event.ghosttyKeyEvent(GHOSTTY_ACTION_PRESS)) { - ghostty_app_key(app, event.ghosttyKeyEvent(GHOSTTY_ACTION_PRESS)) - return nil + // If the key was handled by Ghostty we stop the event chain. If + // the key wasn't handled then we let it fall through and continue + // processing. This is important because some bindings may have no + // affect at this scope. + if (ghostty_app_key( + app, + event.ghosttyKeyEvent(GHOSTTY_ACTION_PRESS))) { + return nil + } } // If this event would be handled by our menu then we do nothing.