From b092f681cf571a1c3068007d1a46633e5ab8b52f Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 19 May 2016 16:49:45 -0700 Subject: QNSView: Reset the internal buttons state after dragging ends We only track left and right mouse buttons when dragging. But some applications may do this with other mouse buttons. In this case, instead of tracking which button was pressed and which one was released, we just ask Cocoa for the current state. Change-Id: I0df7799b7ae6d7816377f881bc0ede867737d245 Task-number: QTBUG-53374 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qnsview.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 0d58faa5bf..6117e3f2e9 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -2070,7 +2070,11 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin // keep our state, and QGuiApplication state (buttons member) in-sync, // or future mouse events will be processed incorrectly - m_buttons &= ~(m_sendUpAsRightButton ? Qt::RightButton : Qt::LeftButton); + NSUInteger pmb = [NSEvent pressedMouseButtons]; + for (int buttonNumber = 0; buttonNumber < 32; buttonNumber++) { // see cocoaButton2QtButton() for the 32 value + if (!(pmb & (1 << buttonNumber))) + m_buttons &= ~cocoaButton2QtButton(buttonNumber); + } NSPoint windowPoint = [self convertPoint: point fromView: nil]; QPoint qtWindowPoint(windowPoint.x, windowPoint.y); -- cgit v1.2.3