diff options
author | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2018-02-27 10:43:48 -0800 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2018-03-07 19:14:07 +0000 |
commit | e16c6dfb7286264ccdfd37d8e74c97f13ece7835 (patch) | |
tree | cbc206c63e84cf2f51240553cd101a28871e420c /src/plugins/platforms/cocoa/qcocoamenubar.mm | |
parent | 4dee5446bee9c7417bf6f5dc44294a0b7238a9ba (diff) |
QCocoaMenuItem: Make QCocoaNSMenu the item target
Since we made the NSMenu delegate a singleton we could not rely
on it to have enough information to implement worksWhenModal.
At the same time as the delegate change, we derived NSMenu into
QCocoaNSMenu. This allows us to extend the menu functionality
and, in this case, serve as target for the Cocoa menu items.
We also refactor setting the item's target/action.
Manually tested against menurama and bigmenucreator tests, the
test-case for QTBUG-17291, and the richtext/textedit example.
Change-Id: I222241f71db82611711b23d4a8c6122a741370ae
Task-number: QTBUG-66676
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoamenubar.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoamenubar.mm | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index 8091d00bda..61ac5eb7f0 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -307,14 +307,12 @@ void QCocoaMenuBar::redirectKnownMenuItemsToFirstResponder() void QCocoaMenuBar::resetKnownMenuItemsToQt() { // Undo the effect of redirectKnownMenuItemsToFirstResponder(): - // set the menu items' actions to itemFired and their targets to - // the QCocoaMenuDelegate. + // reset the menu items' target/action. foreach (QCocoaMenuBar *mb, static_menubars) { foreach (QCocoaMenu *m, mb->m_menus) { foreach (QCocoaMenuItem *i, m->items()) { if (i->effectiveRole() >= QPlatformMenuItem::ApplicationSpecificRole) { - [i->nsItem() setTarget:m->nsMenu().delegate]; - [i->nsItem() setAction:@selector(itemFired:)]; + m->setItemTargetAction(i); } } } |