• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Mouse tracking rects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mouse tracking rects


  • Subject: Re: Mouse tracking rects
  • From: Ricky Sharp <email@hidden>
  • Date: Tue, 8 Mar 2005 21:29:18 -0600


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


  • Follow-Ups:
    • Re: Mouse tracking rects
      • From: Marcel Narings <email@hidden>
References: 
 >Mouse tracking rects (From: Marcel Narings <email@hidden>)
 >Re: Mouse tracking rects (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: drawAtPoint?
  • Next by Date: Re: drawAtPoint?
  • Previous by thread: Re: Mouse tracking rects
  • Next by thread: Re: Mouse tracking rects
  • Index(es):
    • Date
    • Thread