On Apr 26, 2009, at 2:09 PM, Rowan Nairn wrote:

So the little detail is this:  I
don't want to make my whole window transparent to mouse events.  There
are bits of my window on which I want to detect clicks.  Those are the
bits that I've drawn on.  I want the bits I haven't drawn on, the
visually transparent bits, to ignore clicks.

When I use [NSView drawRect:] this works as expected - any pixel that
is visually transparent is also transparent to clicks.  However when I
use a layer (either hosted or backed) the whole area intercepts
clicks, whether visually transparent or not.  I'm starting to think
there's no way around this so I might just go back to [NSView
drawRect:] even though it makes the animation slower.

As far as I know, there is no simple way to do that without drawing (and I didn't know you could do it with drawing).

It occurred to me, however, that you could use Quartz event taps to do this. Event taps let you intercept clicks globally, in any application, and modify them or take other action before you pass them along. You could intercept every mouse event at the global session level (before it is assigned to an application); determine whether its screen location is in your application's window, and which part of that window; set clickthrough on or off in your window depending on whether that area is transparent; and then send the click along. It would automatically go to your application or the application under it, depending on your window's clickthrough setting. I believe this could be made to work with mouse dragged events as well as click events.

You can read about event taps in Apple's "Quartz Event Services Reference" document, and play with them using my free utility, Event Taps Testbench, at <http://prefabsoftware.eventtapstestbench>.

Event taps are complicated if you aren't familiar with them, so if you already have a drawing solution maybe that's the best bet.

--

Bill Cheeseman - b...@cheeseman.name
Quechee Software, Quechee, Vermont, USA
www.quecheesoftware.com

PreFab Software - www.prefabsoftware.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to