Cocoa platform plugin: Add support for up to 16 mouse buttons

OS-X provides a buttonNumber within Event data for otherMouseDown:
and otherMouseUp: Events. Instead of mapping all occurences of these
event types to Qt::MiddleButton, this Update uses that data
to support a total of 16 mouse buttons.

Task-number: QTBUG-24702

Change-Id: I3cffb32498f98ea182509d7c42f3fc6634155ebb
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
This commit is contained in:
Rick Stockton 2012-03-08 14:33:15 -08:00 committed by Qt by Nokia
parent 703b4a0e20
commit 0bb95b183b

View File

@ -336,7 +336,53 @@ static QTouchDevice *touchDevice = 0;
- (void)otherMouseDown:(NSEvent *)theEvent - (void)otherMouseDown:(NSEvent *)theEvent
{ {
m_buttons |= Qt::RightButton; switch ([theEvent buttonNumber]) {
case 3:
m_buttons |= Qt::MiddleButton;
break;
case 4:
m_buttons |= Qt::ExtraButton1; // AKA Qt::BackButton
break;
case 5:
m_buttons |= Qt::ExtraButton2; // AKA Qt::ForwardButton
break;
case 6:
m_buttons |= Qt::ExtraButton3;
break;
case 7:
m_buttons |= Qt::ExtraButton4;
break;
case 8:
m_buttons |= Qt::ExtraButton5;
break;
case 9:
m_buttons |= Qt::ExtraButton6;
break;
case 10:
m_buttons |= Qt::ExtraButton7;
break;
case 11:
m_buttons |= Qt::ExtraButton8;
break;
case 12:
m_buttons |= Qt::ExtraButton9;
break;
case 13:
m_buttons |= Qt::ExtraButton10;
break;
case 14:
m_buttons |= Qt::ExtraButton11;
break;
case 15:
m_buttons |= Qt::ExtraButton12;
break;
case 16:
m_buttons |= Qt::ExtraButton13;
break;
default:
m_buttons |= Qt::MiddleButton;
break;
}
[self handleMouseEvent:theEvent]; [self handleMouseEvent:theEvent];
} }
@ -349,7 +395,53 @@ static QTouchDevice *touchDevice = 0;
- (void)otherMouseUp:(NSEvent *)theEvent - (void)otherMouseUp:(NSEvent *)theEvent
{ {
switch ([theEvent buttonNumber]) {
case 3:
m_buttons &= QFlag(~int(Qt::MiddleButton)); m_buttons &= QFlag(~int(Qt::MiddleButton));
break;
case 4:
m_buttons &= QFlag(~int(Qt::ExtraButton1)); // AKA Qt::BackButton
break;
case 5:
m_buttons &= QFlag(~int(Qt::ExtraButton2)); // AKA Qt::ForwardButton
break;
case 6:
m_buttons &= QFlag(~int(Qt::ExtraButton3));
break;
case 7:
m_buttons &= QFlag(~int(Qt::ExtraButton4));
break;
case 8:
m_buttons &= QFlag(~int(Qt::ExtraButton5));
break;
case 9:
m_buttons &= QFlag(~int(Qt::ExtraButton6));
break;
case 10:
m_buttons &= QFlag(~int(Qt::ExtraButton7));
break;
case 11:
m_buttons &= QFlag(~int(Qt::ExtraButton8));
break;
case 12:
m_buttons &= QFlag(~int(Qt::ExtraButton9));
break;
case 13:
m_buttons &= QFlag(~int(Qt::ExtraButton10));
break;
case 14:
m_buttons &= QFlag(~int(Qt::ExtraButton11));
break;
case 15:
m_buttons &= QFlag(~int(Qt::ExtraButton12));
break;
case 16:
m_buttons &= QFlag(~int(Qt::ExtraButton13));
break;
default:
m_buttons &= QFlag(~int(Qt::MiddleButton));
break;
}
[self handleMouseEvent:theEvent]; [self handleMouseEvent:theEvent];
} }