Using the mouse on Mac OS X

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
bronxbomber92
Posts: 27
Joined: Mon Oct 30, 2006 11:55 pm

Using the mouse on Mac OS X

Post by bronxbomber92 »

Since Mac doesn't have a "right" and "left" click per se, so for checking for mouse clicks, what do you do exactly?
bronxbomber92
Posts: 27
Joined: Mon Oct 30, 2006 11:55 pm

Post by bronxbomber92 »

Does anyone know?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

I suppose your 'mouse mitten' is the left button, but I don't own a mac so you should try it out for yourself. If clicking in the demo fires a shot then it's your left
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
ssexton
Posts: 54
Joined: Wed Oct 25, 2006 7:46 am
Location: South Florida
Contact:

Post by ssexton »

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:

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;
Change NSControlKeyMask to NSCommandKeyMask if you want command (Apple) key instead of control key. You will also need to add a member variable _isctrlclick.
bronxbomber92
Posts: 27
Joined: Mon Oct 30, 2006 11:55 pm

Post by bronxbomber92 »

Thanks! I didn't know Irrlich could be used with objective-c/objective-c++ (why not though :p)
Should be easy enough to make into C++ code.
Post Reply