Different native Cocoa menu fixes.

- Fix location of NSMenu when no NSView is given.
- Fix shortcut when given in text with tab.

Change-Id: Iec21cf3d12084db1e70c1a8779d5482c78285796
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
Christoph Schleifenbaum 2013-10-28 17:11:10 +01:00 committed by The Qt Project
parent 89ab267105
commit aceb854bbb
2 changed files with 19 additions and 11 deletions

View File

@ -466,6 +466,7 @@ void QCocoaMenu::showPopup(const QWindow *parentWindow, QPoint pos, const QPlatf
nsPos.y = screen->availableVirtualSize().height() - nsPos.y;
}
if (view) {
// Finally, we need to synthesize an event.
NSEvent *menuEvent = [NSEvent mouseEventWithType:NSRightMouseDown
location:nsPos
@ -477,6 +478,9 @@ void QCocoaMenu::showPopup(const QWindow *parentWindow, QPoint pos, const QPlatf
clickCount:1
pressure:1.0];
[NSMenu popUpContextMenu:m_nativeMenu withEvent:menuEvent forView:view];
} else {
[m_nativeMenu popUpMenuPositioningItem:nsItem atLocation:nsPos inView:0];
}
}
// The calls above block, and also swallow any mouse release event,

View File

@ -338,6 +338,8 @@ QString QCocoaMenuItem::mergeText()
return qt_mac_applicationmenu_string(4);
} else if (m_native == [loader quitMenuItem]) {
return qt_mac_applicationmenu_string(5).arg(qt_mac_applicationName());
} else if (m_text.contains('\t')) {
return m_text.left(m_text.indexOf('\t'));
}
return m_text;
}
@ -349,6 +351,8 @@ QKeySequence QCocoaMenuItem::mergeAccel()
return QKeySequence(QKeySequence::Preferences);
else if (m_native == [loader quitMenuItem])
return QKeySequence(QKeySequence::Quit);
else if (m_text.contains('\t'))
return QKeySequence(m_text.mid(m_text.indexOf('\t') + 1), QKeySequence::NativeText);
return m_shortcut;
}