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;
|
nsPos.y = screen->availableVirtualSize().height() - nsPos.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, we need to synthesize an event.
|
if (view) {
|
||||||
NSEvent *menuEvent = [NSEvent mouseEventWithType:NSRightMouseDown
|
// Finally, we need to synthesize an event.
|
||||||
location:nsPos
|
NSEvent *menuEvent = [NSEvent mouseEventWithType:NSRightMouseDown
|
||||||
modifierFlags:0
|
location:nsPos
|
||||||
timestamp:0
|
modifierFlags:0
|
||||||
windowNumber:view ? view.window.windowNumber : 0
|
timestamp:0
|
||||||
context:nil
|
windowNumber:view ? view.window.windowNumber : 0
|
||||||
eventNumber:0
|
context:nil
|
||||||
clickCount:1
|
eventNumber:0
|
||||||
pressure:1.0];
|
clickCount:1
|
||||||
[NSMenu popUpContextMenu:m_nativeMenu withEvent:menuEvent forView:view];
|
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,
|
// The calls above block, and also swallow any mouse release event,
|
||||||
|
@ -338,6 +338,8 @@ QString QCocoaMenuItem::mergeText()
|
|||||||
return qt_mac_applicationmenu_string(4);
|
return qt_mac_applicationmenu_string(4);
|
||||||
} else if (m_native == [loader quitMenuItem]) {
|
} else if (m_native == [loader quitMenuItem]) {
|
||||||
return qt_mac_applicationmenu_string(5).arg(qt_mac_applicationName());
|
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;
|
return m_text;
|
||||||
}
|
}
|
||||||
@ -349,6 +351,8 @@ QKeySequence QCocoaMenuItem::mergeAccel()
|
|||||||
return QKeySequence(QKeySequence::Preferences);
|
return QKeySequence(QKeySequence::Preferences);
|
||||||
else if (m_native == [loader quitMenuItem])
|
else if (m_native == [loader quitMenuItem])
|
||||||
return QKeySequence(QKeySequence::Quit);
|
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;
|
return m_shortcut;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user