diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-07-23 15:24:05 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-07-23 15:24:05 (GMT) |
commit | ac7d8acb9d7b2d18335e5482304f837b1c499360 (patch) | |
tree | d3ecaf2a3c701b216fbcdd0248c281bf0401048f /macosx/tkMacOSXMouseEvent.c | |
parent | 259182ceab7c7dda4a411f2fa1ea2475ad7e27d9 (diff) | |
download | tk-ac7d8acb9d7b2d18335e5482304f837b1c499360.zip tk-ac7d8acb9d7b2d18335e5482304f837b1c499360.tar.gz tk-ac7d8acb9d7b2d18335e5482304f837b1c499360.tar.bz2 |
Fix [38dc27bd1d]: Tk does not support <Button-6> nor <Button-7> events. Now handle all events up to Button 9.
On Windows and Mac, Buttons 8 and 9 are used for the mouse side buttons (as X11 already does). TIP needed for this.
Diffstat (limited to 'macosx/tkMacOSXMouseEvent.c')
-rw-r--r-- | macosx/tkMacOSXMouseEvent.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 2517769..42fae98 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -178,22 +178,26 @@ enum { */ unsigned int state = 0; - NSInteger button = [theEvent buttonNumber]; + int button = [theEvent buttonNumber]; + if (++button > 3) { + button += 4; /* Map buttons 4/5 to 8/9 */ + } EventRef eventRef = (EventRef)[theEvent eventRef]; UInt32 buttons; OSStatus err = GetEventParameter(eventRef, kEventParamMouseChord, typeUInt32, NULL, sizeof(UInt32), NULL, &buttons); if (err == noErr) { - state |= (buttons & ((1<<5) - 1)) << 8; - } else if (button < 5) { + state |= (buttons & 0x07) << 8; + state |= (buttons & 0x18) << 12; + } else if (button <= 9) { switch (eventType) { case NSLeftMouseDown: case NSRightMouseDown: case NSLeftMouseDragged: case NSRightMouseDragged: case NSOtherMouseDown: - state |= 1 << (button + 8); + state |= TkGetButtonMask(button); break; default: break; @@ -361,10 +365,11 @@ ButtonModifiers2State( unsigned int state; /* - * Tk supports at most 5 buttons. + * Tk on OSX supports at most 5 buttons. */ - state = (buttonState & ((1<<5) - 1)) << 8; + state = (buttonState & 0x07) * Button1Mask; + state |= (buttonState & 0x18) * (Button8Mask >> 3); if (keyModifiers & alphaLock) { state |= LockMask; |