Cocoa: Reset the target + action for a menuitem after showing a dialog
To make it more reliable and efficient we now do the reverse of what we are doing when redirecting the items. This will ensure that the actions are correctly reset to the original target and action. The original approach of updateMenubarImmediately() was not always doing this and it also does other unnecessary things as a result when all we need is to just reset the things we changed. Change-Id: Icefa38d47ec9434894f05caeed75fbf8bdfecb93 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
9b91784987
commit
3e8ebea95b
@ -303,7 +303,23 @@ void QCocoaMenuBar::resetKnownMenuItemsToQt()
|
||||
// Undo the effect of redirectKnownMenuItemsToFirstResponder():
|
||||
// set the menu items' actions to itemFired and their targets to
|
||||
// the QCocoaMenuDelegate.
|
||||
updateMenuBarImmediately();
|
||||
foreach (QCocoaMenuBar *mb, static_menubars) {
|
||||
foreach (QCocoaMenu *m, mb->m_menus) {
|
||||
foreach (QCocoaMenuItem *i, m->items()) {
|
||||
switch (i->effectiveRole()) {
|
||||
case QPlatformMenuItem::CutRole:
|
||||
case QPlatformMenuItem::CopyRole:
|
||||
case QPlatformMenuItem::PasteRole:
|
||||
case QPlatformMenuItem::SelectAllRole:
|
||||
[i->nsItem() setTarget:m->nsMenu().delegate];
|
||||
[i->nsItem() setAction:@selector(itemFired:)];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QCocoaMenuBar::updateMenuBarImmediately()
|
||||
|
Loading…
x
Reference in New Issue
Block a user