Re: Mouse tracking rects
Re: Mouse tracking rects
- Subject: Re: Mouse tracking rects
- From: Marcel Narings <email@hidden>
- Date: Thu, 10 Mar 2005 21:12:26 +0100
Thanks,
This works great
Marcel
On Mar 9, 2005, at 04:29, Ricky Sharp wrote:
On Mar 8, 2005, at 6:19 PM, Nick Zitzmann wrote:
On Mar 8, 2005, at 4:57 PM, Marcel Narings wrote:
This works perfectly. However when my app starts with the mouse over
the view; I first have to move the mouse out of the view and then
back over.
How do I get mouseMoved events when my app starts up with the mouse
over the view? Where do I place the [ [self window]
setAcceptsMouseMovedEvents:YES] ?
I solved this problem once by overriding -viewDidMoveToWindow,
calling the method to set up the tracking rects in the override, and
in the method that sets up the tracking rects I made it check the
current mouse position and call -mouseEntered: manually if the
pointer is already inside the rect. This works for me...
It may be better to obtain a correct value for the assumeInside
parameter:
- (void)viewDidMoveToWindow
{
NSWindow* theWindow = [self window];
if (theWindow != nil)
{
NSPoint theMouseLocation = [theWindow
mouseLocationOutsideOfEventStream];
NSRect theBounds = [self bounds];
BOOL theAssumeInsideFlag = NSMouseInRect (
[self convertPoint:theMouseLocation fromView:nil],
theBounds, YES);
... your call to addTrackingRect here ...
if (theAssumeInsideFlag)
{
[theWindow setAcceptsMouseMovedEvents:YES];
}
}
}
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
--
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden