Re: Transparent window not getting mouse down events
Re: Transparent window not getting mouse down events
- Subject: Re: Transparent window not getting mouse down events
- From: Ron Fleckner <email@hidden>
- Date: Wed, 01 Feb 2012 15:24:03 +1100
On 01/02/2012, at 7:59 AM, Marshall Houskeeper wrote:
> I would like to create a transparent window that spans all the screens and that handles mouse down events. Below is the code that I use to create my transparent window. The transparent window gets created and display successfully. However, mouse down events are not directed to the window. I can see where this feature is desirable. For example making a round window. However, not in my case.
>
> Is there a way that I can setup a transparent window to receive mouse down events?
>
> Note: I have found that if I set the window's background color alpha value to 0.05 or greater I will receive mouse down events. However this little amount of alpha causes some color shift in the background image.
>
> - (id)init
> {
> NSRect rect = [[NSScreen mainScreen] frame];
>
> // get the union of all the screens
> for (NSScreen* s in [NSScreen screens])
> {
> rect = NSUnionRect(rect,[s frame]);
> }
>
> self = [super initWithContentRect:rect styleMask:NSBorderlessWindowMask backing:NSBackingStoreRetained defer:YES];
>
> if (self)
> {
> [self setBackgroundColor:[NSColor clearColor]];
> [self setOpaque:NO];
> }
>
> return self;
> }
>
Hi,
NSWindow has:
setIgnoresMouseEvents:
Specifies whether the window is transparent to mouse clicks and other mouse events, allowing overlay windows.
- (void)setIgnoresMouseEvents:(BOOL)ignoreMouseEvents
Parameters
ignoreMouseEvents
If YES, the window will ignore mouse events; if NO, it will not.
Availability
• Available in Mac OS X v10.2 and later.
Ron
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden