From f6cc1f3aeae795e7ed67338b17b860df9f5146a7 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 3 Dec 2012 22:03:53 +0100 Subject: Ensure ctrl + click sends a right mouse button press in Cocoa MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since Mac's typically just have one button for their mice then pressing Control then clicking the button should end it as a right mouse button event. Task-number: QTBUG-28350 Change-Id: Iabcac5b315c36cb8cd062c27d7b1506bc066f5bb Reviewed-by: Liang Qi Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qnsview.h | 1 + src/plugins/platforms/cocoa/qnsview.mm | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index f93fd86205..9cdfe6f5bb 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -66,6 +66,7 @@ QT_END_NAMESPACE QString m_composingText; bool m_sendKeyEvent; QStringList *currentCustomDragTypes; + bool m_sendUpAsRightButton; Qt::KeyboardModifiers currentWheelModifiers; bool m_subscribesForGlobalFrameNotifications; } diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index b608989e43..eea65cf8c0 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -84,6 +84,7 @@ static QTouchDevice *touchDevice = 0; m_sendKeyEvent = false; m_subscribesForGlobalFrameNotifications = false; currentCustomDragTypes = 0; + m_sendUpAsRightButton = false; if (!touchDevice) { touchDevice = new QTouchDevice; @@ -427,6 +428,7 @@ static QTouchDevice *touchDevice = 0; - (void)mouseDown:(NSEvent *)theEvent { + m_sendUpAsRightButton = false; if (m_platformWindow->m_activePopupWindow) { QWindowSystemInterface::handleCloseEvent(m_platformWindow->m_activePopupWindow); QWindowSystemInterface::flushWindowSystemEvents(); @@ -438,7 +440,12 @@ static QTouchDevice *touchDevice = 0; [inputManager handleMouseEvent:theEvent]; } } else { - m_buttons |= Qt::LeftButton; + if ([self convertKeyModifiers:[theEvent modifierFlags]] & Qt::MetaModifier) { + m_buttons |= Qt::RightButton; + m_sendUpAsRightButton = true; + } else { + m_buttons |= Qt::LeftButton; + } [self handleMouseEvent:theEvent]; } } @@ -452,7 +459,12 @@ static QTouchDevice *touchDevice = 0; - (void)mouseUp:(NSEvent *)theEvent { - m_buttons &= QFlag(~int(Qt::LeftButton)); + if (m_sendUpAsRightButton) { + m_buttons &= QFlag(~int(Qt::RightButton)); + m_sendUpAsRightButton = false; + } else { + m_buttons &= QFlag(~int(Qt::LeftButton)); + } [self handleMouseEvent:theEvent]; } -- cgit v1.2.3