Re: why NSTrackingArea doesn't work?
Re: why NSTrackingArea doesn't work?
- Subject: Re: why NSTrackingArea doesn't work?
- From: Nick <email@hidden>
- Date: Thu, 23 Jun 2011 09:45:56 +0300
Thanks a lot, It worked! :-)
I was creating a custom window, and wanted to make the "close/minimize/zoom"
buttons to behave naturally.
The only thing that isn't working in my custom window - is the
"click-through" on the [NSWindow standardWindowButton] button (I am using a
"fake" titlebar).
Whenever the window is not main/key and I click on the button, I get to
click twice -first to activate the window (make it main), second to actually
click on the, for example, "close" button.
Other "ordinary" cocoa buttons (NSPushButton) placed on this view allow
clicking on them directly when the view is not active.
These "close/minimize/zoom" buttons are placed on a view, that returns "YES"
in a -(BOOL)acceptsFirstMouse:(NSEvent *)theEvent
method.
Well this is ignored, and for some weird reason, by default, the views,
returned by [NSWindow standardWindowButton], return "NO" for
acceptsFirstMouse (since i need to click twice). And I can't even sublass
them to change what's happening.
Maybe you can suggest something? Should I build the buttons from scratch,
drawing all the icons by myself to make it behave real?
Thank you
2011/6/23 Ken Thomases <email@hidden>
> On Jun 22, 2011, at 7:41 PM, Conrad Shultz wrote:
>
> > On 6/22/11 5:04 PM, Nick wrote:
> >> NSTrackingArea* trackingArea = [[NSTrackingArea alloc]
> initWithRect:[self
> >> frame] options: (NSTrackingMouseEnteredAndExited |
> NSTrackingActiveAlways)
> >> owner:self userInfo:nil];
> >
> > Don't use [self frame]... that is in the superview's coordinate system,
> > not the tracking area's view's coordinate space (which is expected).
> >
> > Use [self bounds] instead; depending on the absolute position of your
> > view this might make a HUGE difference.
>
> I strongly recommend considering use of NSTrackingInVisibleRect, too. If
> your view changes windows or moves within its window, this will make things
> a lot simpler. It can be the wrong thing in rare cases, but I'd be
> surprised if you need one of those.
>
> Regards,
> Ken
>
>
_______________________________________________
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