diff options
author | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2018-03-28 18:07:30 -0700 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2018-04-19 22:19:46 +0000 |
commit | b7be91b5f28cd42e6f9898f480fa12a0cd359a84 (patch) | |
tree | 78a8d28dd227d12afbd95677e8a4932ed1ca319a /src/plugins/platforms/cocoa/qcocoamenubar.h | |
parent | 0b9a301e89c6473091a9b80552d6e4058d35bbe6 (diff) |
Cocoa Menus: Use the responder chain for menu items target/action
We start by setting the menu item target to nil.
Then, -[qt_itemFired:] action is now in QNSView, which itself is
naturally inserted in the responder chain. This removes the need
to track and change the menu item's target/action when we're
displaying a native dialog. Part of this is possible because we
now derive our own QCocoaNSMenuItem class from NSMenuItem.
We use -[respondsToSelector:] to decide whether the QNSView in
the responder chain should respond to cut:, copy:, etc. And we
only return YES when the view is first responder. The invocation
to these action is forwarded to the same views' -[qt_itemFired:].
Message forwarding is done via forwardInvocation:, but experiments
have shown that it can be done by the sole means of respondsToSelector:
and direct invocation from cut:, copy:, etc. See the usage of the
macro QT_COCOA_DYNAMIC_MENU_ITEM_ACTION.
Menu validation also happens in QNSView and looks for modal windows.
Therefore, -[worksWhenModal] is no longer necessary. Also, since the
target is no longer set, the logic as documented in NSMenuItem.target
won't work anymore.
Most items from QCocoaMenuLoader also become QCocoaNSMenuItem and
get the same target/action, which removes a bit of duplicated (and
outdated) code. A particular case is the Quit item, which gets the
terminate: action set until an actual menu item is added.
Tested with texedit and standard dialogs examples together with
menus, menurama and bigmenucreator manual tests.
We also renamed some functions and variables to reflect common
naming practices.
Change-Id: I9b51d3be3467a666d8c3dcf8585edbc821e0282e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoamenubar.h')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoamenubar.h | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.h b/src/plugins/platforms/cocoa/qcocoamenubar.h index 6f3aca3a51..fbf6c49eeb 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.h +++ b/src/plugins/platforms/cocoa/qcocoamenubar.h @@ -65,8 +65,6 @@ public: inline NSMenu *nsMenu() const { return m_nativeMenu; } - static void redirectKnownMenuItemsToFirstResponder(); - static void resetKnownMenuItemsToQt(); static void updateMenuBarImmediately(); QList<QCocoaMenuItem*> merged() const; |