FROM : David Duncan
DATE : Mon Jan 07 22:55:06 2008
On Jan 4, 2008, at 1:51 PM, Tom Pusateri wrote:
> I have a single NSView in which I've created many CATextLayers to form
> a menu that can slide over. I would like to expand a menu item if you
> hover the mouse on the right edge of the CATextLayer. NSTrackingArea
> seems to be a good fit except that it is view centric and not layer
> centric. I thought about creating an NSTrackingArea for each layer
> once the layers are positioned but after adding the constraints, I
> don't know how to determine the layers position. There isn't a
> delegate method or anyway to know when the layer position has been
> calculated so I know where to create the NSTrackingArea. Of course,
> then I have to deal with moving the tracking areas each time the layer
> moves. Should I just used mouseMoved even though its less efficient?
> Then how do I know which layer the mouse position is over?
I would create a tracking area for the entire NSView, and whenever you
notified of a mouse move, the use CALayer's -hitTest method to
determine which layer is under the mouse. If you create a layer
specifically for your "expand" area then you can easily track it
seperately (just set the name property on that layer!)
--
David Duncan
Apple DTS Animation and Printing
david.<email_removed>
DATE : Mon Jan 07 22:55:06 2008
On Jan 4, 2008, at 1:51 PM, Tom Pusateri wrote:
> I have a single NSView in which I've created many CATextLayers to form
> a menu that can slide over. I would like to expand a menu item if you
> hover the mouse on the right edge of the CATextLayer. NSTrackingArea
> seems to be a good fit except that it is view centric and not layer
> centric. I thought about creating an NSTrackingArea for each layer
> once the layers are positioned but after adding the constraints, I
> don't know how to determine the layers position. There isn't a
> delegate method or anyway to know when the layer position has been
> calculated so I know where to create the NSTrackingArea. Of course,
> then I have to deal with moving the tracking areas each time the layer
> moves. Should I just used mouseMoved even though its less efficient?
> Then how do I know which layer the mouse position is over?
I would create a tracking area for the entire NSView, and whenever you
notified of a mouse move, the use CALayer's -hitTest method to
determine which layer is under the mouse. If you create a layer
specifically for your "expand" area then you can easily track it
seperately (just set the name property on that layer!)
--
David Duncan
Apple DTS Animation and Printing
david.<email_removed>
| Related mails | Author | Date |
|---|---|---|
| Tom Pusateri | Jan 4, 22:51 | |
| David Duncan | Jan 7, 22:55 |






Cocoa mail archive

