From 886fe7e69f61fff5c58e1d84c640398c97a4c1ab Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sun, 6 Dec 2020 20:53:29 +0000 Subject: [PATCH] LibGUI: Allow GUI::Action to swallow key events when disabled Sometimes an action should be disabled and the KeyEvent not posted to the app's event loop nonetheless. In other words the action swallows the KeyEvent without being activated. Specific use-case: Terminal's Ctrl+Shift+{C,V}. --- Libraries/LibGUI/Action.h | 4 ++++ Libraries/LibGUI/WindowServerConnection.cpp | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Libraries/LibGUI/Action.h b/Libraries/LibGUI/Action.h index 44bb3ec223..8b1f9f4d1d 100644 --- a/Libraries/LibGUI/Action.h +++ b/Libraries/LibGUI/Action.h @@ -132,6 +132,9 @@ public: } void set_checked(bool); + bool swallow_key_event_when_disabled() const { return m_swallow_key_event_when_disabled; } + void set_swallow_key_event_when_disabled(bool swallow) { m_swallow_key_event_when_disabled = swallow; } + void register_button(Badge