Get mouse button state in OSX

460 Views Asked by At

Is there any way to query the state of mouse buttons in OSX? In other words, I am looking for a function that returns whether a mouse button is currently being pressed or not. The equivalent under Windows would be GetAsyncKeyState(VK_LBUTTON).

This is in the context of a Quartz event if that matters. I found the promising function CGEventSourceFlagsState that, when called with kCGEventSourceStateHIDSystemState returns that information for the CONTROL, SHIFT, ALT keys but from what I can see, unfortunately not for mouse buttons.

1

There are 1 best solutions below

0
user3700562 On

Seems like CGEventSourceButtonState might just be what I am looking for.