summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoahelpers.mm
diff options
context:
space:
mode:
authorRick Stockton <rickstockton@reno-computerhelp.com>2012-12-20 20:38:45 -0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-25 23:17:58 +0100
commitf210a8593450049fc366098cab040daea10ca758 (patch)
tree282dc9ba9bda4080dc90ebc30304d8da291536fa /src/plugins/platforms/cocoa/qcocoahelpers.mm
parent6f1f8934938f0b79a30b034093633aa336da1323 (diff)
cocoa: Fix Mouse Event tracking of button status
Within qcocoahelpers, make function cocoaButton2QtButton() handle all button numbers. Within qnsview, call the function in several places (eliminating duplicate, inefficient code). Task-number: QTBUG-28567 Change-Id: Ibae2ae4e8a881b825a8862afb82aa80437751111 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com> Reviewed-by: Rick Stockton <rickstockton@reno-computerhelp.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoahelpers.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index c6d6e35794..0c5d26054c 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -623,20 +623,17 @@ CGFloat qt_mac_get_scalefactor()
Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum)
{
- switch (buttonNum) {
- case 0:
+ if (buttonNum == 0)
return Qt::LeftButton;
- case 1:
+ if (buttonNum == 1)
return Qt::RightButton;
- case 2:
- return Qt::MidButton;
- case 3:
- return Qt::XButton1;
- case 4:
- return Qt::XButton2;
- default:
- return Qt::NoButton;
+ if (buttonNum == 2)
+ return Qt::MiddleButton;
+ if (buttonNum >= 3 && buttonNum <= 31) { // handle XButton1 and higher via logical shift
+ return Qt::MouseButton(uint(Qt::MiddleButton) << (buttonNum - 3));
}
+ // else error: buttonNum too high, or negative
+ return Qt::NoButton;
}
bool qt_mac_execute_apple_script(const char *script, long script_len, AEDesc *ret) {