• 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: Event handling question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Event handling question (From: "Christian Moen" <email@hidden>)

  • Prev by Date: Event handling question
  • Next by Date: No double click event available to an NSView?
  • Previous by thread: Event handling question
  • Next by thread: No double click event available to an NSView?
  • Index(es):
    • Date
    • Thread