d3d
d3d

Reputation: 13

capture a click event that occurs on the desktop(not on a file / folder / window)

I would like to be able to detect in cocoa(or actionscript, but cocoa preferably) when the user has double-clicked the desktop, and not a folder/icon/window, to trigger a follow up function.

Is anyone aware of a means of triggering a function in cocoa(or applescript) after the desktop was clicked, or better yet double-clicked?

I've considered drawing a transparent window the size of the desktop on top of the desktop, but haven't found a way to allow for the mouse clicks to fall through the transparent-window onto desktop items(files, folders, etc), so the process is transparent to the user with this method. And getting this to run on multiple displays in Lion might be a bit troublesome.

Ideally, I'm hoping to find some API calls to capture clicks on the desktop, they seem to be there due to the ability to right click the desktop, and get the desktop-specific contextual menu items.

Upvotes: 1

Views: 328

Answers (1)

Julien
Julien

Reputation: 3477

Your best bet is to use +[NSEvent addGlobalMonitorForEventsMatchingMask:handler:] then figure out if you are interested in the event or not.

See this other question for more info.

Upvotes: 1

Related Questions