diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-10-14 18:10:36 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-10-16 14:33:29 +0200 |
commit | 848e3855f922e56a156ab8275f45cfb7a361acb5 (patch) | |
tree | e4cc8efbbf6f7d56e7fce65a01038192ea84c067 /src/plugins | |
parent | 3007050db74705f14515908b3c20ef5d1963d895 (diff) |
macOS: Don't require marked text before passing mouse down to input context
There are situations where the input context might want the event,
even if there's no marked text, for example when long-pressing A
with a US keyboard layout and getting the accent popup. In that
case we want a press somewhere else in the input item to move the
cursor, and commit the current preedit.
This is the same approach as NSTextView has, always calling
handleEvent, and in line with the recommendation from Apple:
https://lists.apple.com/archives/cocoa-dev/2012/May/msg00539.html
Pick-to: 6.2
Change-Id: Iff0861a4e604ab594d1ad4ccbb9367d8e0ffe4ef
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview_mouse.mm | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview_mouse.mm b/src/plugins/platforms/cocoa/qnsview_mouse.mm index e3343c4c1a..559257c4df 100644 --- a/src/plugins/platforms/cocoa/qnsview_mouse.mm +++ b/src/plugins/platforms/cocoa/qnsview_mouse.mm @@ -429,13 +429,16 @@ static const QPointingDevice *pointingDeviceFor(qint64 deviceID) return; } - // FIXME: AppKit doesn't limit itself to passing the event on to the input method - // based on there being marked text or not. It also transfers first responder to - // the view before calling mouseDown, whereas we only transfer focus once the mouse - // press is delivered. - if ([self hasMarkedText]) { + // FIXME: AppKit transfers first responder to the view before calling mouseDown, + // whereas we only transfer focus once the mouse press is delivered, which means + // on first click the focus item won't be the correct one when transferring focus. + auto *focusObject = m_platformWindow->window()->focusObject(); + if (queryInputMethod(focusObject)) { + // Input method is enabled. Pass on to the input context if we + // are hitting the input item. if (QPlatformInputContext::inputItemClipRectangle().contains(qtWindowPoint)) { - qCDebug(lcQpaInputMethods) << "Asking input context to handle mouse press"; + qCDebug(lcQpaInputMethods) << "Asking input context to handle mouse press" + << "for focus object" << focusObject; if ([NSTextInputContext.currentInputContext handleEvent:theEvent]) { // NSTextView bails out if the input context handled the event, // which is e.g. the case for 2-Set Korean input. We follow suit, |