Just wondering if there is a way to receive a callback in Cocoa if Magic Mouse or Trackpad is being touched by the user?
I looked into Quartz Events, but it seems I can only get callbacks if the mouse is moving or clicked etc.
Note that I want to receive a callback even if my app is not active. It's a background utility app. Also, it can't use private frameworks as it's going to be a Mac App Store app.
You could use this code to trap the events: (create a new Cocoa application and put this in the application delegate)
but.. sandboxing will probably prevent you from using
CGEventTapCreate
because by nature, it allows an application to listen to the whole event system, which is not very secure. If not using the sandboxing is acceptable to you, theneventTapCallback
is called when a new touch is made on the touchpad.