1

I have a CGEventTap and I would like to observe and process all system mouse click events. Detecting a mouse click event is easy, but I don’t want some of the clicks to get processed by the rest of the system. And I can’t figure out how.

The system only sends low-level events like mouseUp, mouseDown, mouseDragged and so on. When I receive a mouseDown event, I don’t know if it’s a part of a mouse click yet, could be a drag event. I have to wait for the following event – if it’s a mouseUp, I have a click. But if I want to process the click myself and keep it from going down the rest of the event queue, I can’t simply steal the mouseUp event, as the previous mouseDown was already sent.

I thought I could delay the mouseDown event and only send it later after receiving the corresponding mouseUp, but that feels wrong, I don’t want to delay all system mouseDown events just because of my application. Am I missing something?

skaffman
  • 398,947
  • 96
  • 818
  • 769
zoul
  • 102,279
  • 44
  • 260
  • 354
  • 1
    Why do you think you might be missing something? What makes you think you should be able to do this? – hooleyhoop Feb 15 '11 at 23:50
  • I thougth that maybe there’s an easier way to monitor and change all system mouse events. I can observe and filter the key events just fine this way, it seems strange that it should be impossible to do the same with a simple mouse click. – zoul Feb 16 '11 at 07:25

1 Answers1

0

What you thought is actually right. You have to postpone mouse down event for the time interval equal to a mouse double click speed, that should be around 100-500 milliseconds. User will not notice a 100 millisecond delay, for example. Ideally, you should a value from Mac OS X mouse settings to make a good user experience.