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:
parent
89ab267105
commit
aceb854bbb
@ -466,17 +466,21 @@ void QCocoaMenu::showPopup(const QWindow *parentWindow, QPoint pos, const QPlatf
|
||||
nsPos.y = screen->availableVirtualSize().height() - nsPos.y;
|
||||
}
|
||||
|
||||
// Finally, we need to synthesize an event.
|
||||
NSEvent *menuEvent = [NSEvent mouseEventWithType:NSRightMouseDown
|
||||
location:nsPos
|
||||
modifierFlags:0
|
||||
timestamp:0
|
||||
windowNumber:view ? view.window.windowNumber : 0
|
||||
context:nil
|
||||
eventNumber:0
|
||||
clickCount:1
|
||||
pressure:1.0];
|
||||
[NSMenu popUpContextMenu:m_nativeMenu withEvent:menuEvent forView:view];
|
||||
if (view) {
|
||||
// Finally, we need to synthesize an event.
|
||||
NSEvent *menuEvent = [NSEvent mouseEventWithType:NSRightMouseDown
|
||||
location:nsPos
|
||||
modifierFlags:0
|
||||
timestamp:0
|
||||
windowNumber:view ? view.window.windowNumber : 0
|
||||
context:nil
|
||||
eventNumber:0
|
||||
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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user