macOS: Hide mouse cursor when initiating IM enabled text input

Fixes: QTBUG-72744
Pick-to: 6.2
Change-Id: I952710e88a11fd00498562c9011461a010f02f7b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Tor Arne Vestbø 2021-08-27 17:42:48 +02:00
parent 3de396590c
commit 52f635b9a0

View File

@ -88,6 +88,19 @@
// unless we explicit set m_sendKeyEvent to deliver as a normal key event.
m_sendKeyEvent = false;
// Match NSTextView's keyDown behavior of hiding the cursor before
// interpreting key events. Shortcuts should not trigger this though.
// Unfortunately many of our controls handle shortcuts by accepting
// the ShortcutOverride event and then handling the shortcut in the
// following key event, and QWSI::handleShortcutEvent doesn't reveal
// whether this will be the case. For NSTextView this is not an issue
// as shortcuts are handled via performKeyEquivalent, which happens
// prior to keyDown. To work around this until we can get the info
// we need from handleShortcutEvent we match AppKit and assume that
// any key press with a command or control modifier is a shortcut.
if (!(nsevent.modifierFlags & (NSEventModifierFlagCommand | NSEventModifierFlagControl)))
[NSCursor setHiddenUntilMouseMoves:YES];
qCDebug(lcQpaKeys) << "Interpreting key event for focus object" << focusObject;
m_currentlyInterpretedKeyEvent = nsevent;
[self interpretKeyEvents:@[nsevent]];