title: How do I process a mouse click using Quartz events?
body: <p>I have a <code>CGEventTap</code> 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.</p>
  
  <p>The system only sends low-level events like <code>mouseUp</code>, <code>mouseDown</code>, <code>mouseDragged</code> and so on. When I receive a <code>mouseDown</code> 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 <code>mouseUp</code>, 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 <code>mouseUp</code> event, as the previous <code>mouseDown</code> was already sent.</p>
  
  <p>I thought I could delay the <code>mouseDown</code> event and only send it later after receiving the corresponding <code>mouseUp</code>, but that feels wrong, I don’t want to delay all system <code>mouseDown</code> events just because of my application. Am I missing something?</p>