Is there a way to report every mouse click on the application dock icon?
Asked
Active
Viewed 1,379 times
2 Answers
9
Not completely safe (also activated by double-click on the application itself),
but definitely the most easy way to implement:
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
Quote from NSApplicationDelegate Protocol Reference:
These events are sent whenever the Finder reactivates an already running application because someone double-clicked it again or used the dock to activate it.

Anne
- 26,765
- 9
- 65
- 71
-
I already got that one. I use it to popup a nsmenu. But once to menu is open I get no call on that function. – Matthieu Riegler Jul 04 '12 at 18:42
-
My mistake. If `applicationShouldHandleReopen` isn't called it's because the menu is kind of modal. – Matthieu Riegler Jul 04 '12 at 18:50
1
I would like to suggest an alternative solution to the answer provided by Anne, which avoids conflicting with the event in which the user double clicks on the application icon, instead of on the dock icon.
Thus, I suggest to use
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender;
See also the Apple's documentation.

Andrea Alberti
- 186
- 1
- 9