Using the mouse on Mac OS X
-
- Posts: 27
- Joined: Mon Oct 30, 2006 11:55 pm
Using the mouse on Mac OS X
Since Mac doesn't have a "right" and "left" click per se, so for checking for mouse clicks, what do you do exactly?
The mitten is left-click.
For right-click, you check modifier keys. The OS uses ctrl-click to mean "right-click". Other programs use command-click to mean "right-click".
For a game, command-click is better, since only the Mac has a command (aka Apple) key. Then there is no platform issue if in your game you want to have ctrl-left-click do something different than left-click.
I just did this in OSIrrlichtDevice, except right now I have it as control key to match the OS. Here is the code for CIrrDeviceMacOSX.mm:
Change NSControlKeyMask to NSCommandKeyMask if you want command (Apple) key instead of control key. You will also need to add a member variable _isctrlclick.
For right-click, you check modifier keys. The OS uses ctrl-click to mean "right-click". Other programs use command-click to mean "right-click".
For a game, command-click is better, since only the Mac has a command (aka Apple) key. Then there is no platform issue if in your game you want to have ctrl-left-click do something different than left-click.
I just did this in OSIrrlichtDevice, except right now I have it as control key to match the OS. Here is the code for CIrrDeviceMacOSX.mm:
Code: Select all
case NSLeftMouseDown:
ievent.EventType = irr::EET_MOUSE_INPUT_EVENT;
if ([event modifierFlags] & NSControlKeyMask) {
_isctrlclick = true;
ievent.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN;
} else {
_isctrlclick = false;
ievent.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN;
}
postMouseEvent(event,ievent);
break;
case NSLeftMouseUp:
ievent.EventType = irr::EET_MOUSE_INPUT_EVENT;
if (_isctrlclick)
ievent.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP;
else
ievent.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP;
postMouseEvent(event,ievent);
break;
-
- Posts: 27
- Joined: Mon Oct 30, 2006 11:55 pm