macOS: map Qt::Key_Return to NSCarriageReturnCharacter in menus
On macOS, key combinations with the Return key do not get delivered through NSView::keyDown, but they are seen by the QCocoaNSMenu::menuHasKeyEquivalent override. We already use that override to check whether any menu item uses a matching shortcut, and give Qt's focus object a chance to override the shortcut. The key mapper used the NSNewlineCharacter '\n' for Qt::Key_Return. However, the character we get from macOS for the return key is the NSCarriageReturnCharacter character, '\r'. This makes the lookup fail, and shortcut overrides are not delivered for shortcuts using Qt::Key_Return. To fix this, map Qt::Key_Return to NSCarriageReturnCharacter. The inverse mapping maps both NSCarriageReturnCharacter and NSNewlineCharacter to Qt::Key_Return, and there are no other users of this function in Qt. Pick-to: 6.5 6.4 Fixes: QTBUG-107526 Change-Id: I716190adf3cd94697e2b3ad1afc25b95d8ebde25 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
f11e5435c7
commit
0835537c3c
@ -360,7 +360,7 @@ QChar QAppleKeyMapper::toCocoaKey(Qt::Key key)
|
||||
{
|
||||
// Prioritize overloaded keys
|
||||
if (key == Qt::Key_Return)
|
||||
return QChar(NSNewlineCharacter);
|
||||
return QChar(NSCarriageReturnCharacter);
|
||||
if (key == Qt::Key_Backspace)
|
||||
return QChar(NSBackspaceCharacter);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user