Re: Event handling question
Re: Event handling question
- Subject: Re: Event handling question
- From: Ricky Sharp <email@hidden>
- Date: Sun, 4 Feb 2007 08:15:03 -0600
On Feb 4, 2007, at 6:08 AM, Christian Moen wrote:
I'm working on an application with a custom view and I have a question
on event handling.
My custom view area contains several tracking rects which capture
mouse movement in the view. As the user moves his mouse, I'd like to
highlight the active part of the view indicated by the tracking rect
being entered. This works fine when the user moves the mouse and
activates a new tracking rect.
My question is: How should I handle a window with my custom view being
opened under the mouse pointer? My custom view doesn't seem get an
initial mouseEntered: call.
Should I send a mouseEntered event myself in the custom view's
awakeFromNib method by getting the mouse position using NSWindow's
mouseLocationOutsiteOfEventStream and converting this the view
coordinates?
Yes. Look at wherever you are calling
addTrackingRect:owner:userData:assumeInside: and see if you need to
pass YES to assumeInside.
For my custom views, I do all this work inside viewDidMoveToWindow
- (void)viewDidMoveToWindow
{
NSWindow* theWindow = [self window];
NSPoint theMouseLocation = [theWindow
mouseLocationOutsideOfEventStream];
NSRect theBounds = [self bounds];
BOOL theAssumeInsideFlag = NSMouseInRect ([self
convertPoint:theMouseLocation
fromView:nil], theBounds, [self isFlipped]);
... code to add tracking rect
}
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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