summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-10-14 16:27:31 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-10-16 14:33:29 +0200
commitc67f46877c72d1c04cb643f33e820d86e64128d1 (patch)
treec728cac81271d779e2a106a294294871497b5359 /src/plugins
parent1dfc74970c8ab0bfc210b7038aad401189eae542 (diff)
macOS: Only send mouse press to input context if clicking input item
Our QNSView can represent many controls, not just the current input item, so we need to ensure the click happens inside the input item before we ask the input context to handle the event. This allows clicking controls such as buttons and check boxes while composing complex text, without cancelling or otherwise affecting the composition. Fixes: QTBUG-57347 Pick-to: 6.2 Change-Id: I8449c8d74fd21b1ee1d5bd75f960751b64d7e078 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/cocoa/qnsview_mouse.mm15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview_mouse.mm b/src/plugins/platforms/cocoa/qnsview_mouse.mm
index 8ea509e54a..f9038e08da 100644
--- a/src/plugins/platforms/cocoa/qnsview_mouse.mm
+++ b/src/plugins/platforms/cocoa/qnsview_mouse.mm
@@ -429,9 +429,20 @@ static const QPointingDevice *pointingDeviceFor(qint64 deviceID)
return;
}
+ bool handleMouseEvent = true;
+ // 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]) {
- [[NSTextInputContext currentInputContext] handleEvent:theEvent];
- } else {
+ if (QPlatformInputContext::inputItemClipRectangle().contains(qtWindowPoint)) {
+ qCDebug(lcQpaInputMethods) << "Asking input context to handle mouse press";
+ [NSTextInputContext.currentInputContext handleEvent:theEvent];
+ handleMouseEvent = false;
+ }
+ }
+
+ if (handleMouseEvent) {
if (!m_dontOverrideCtrlLMB && (theEvent.modifierFlags & NSEventModifierFlagControl)) {
m_buttons |= Qt::RightButton;
m_sendUpAsRightButton = true;