NSImage mouse events
I have a number of NSImages that I'm rendering in a custom NSView subclass. I'm looking to enlarge theses images as and when the user 开发者_C百科places their mouse over them and am wondering about the best way to go about doing this.
Currently I'm using the NSView's drawRect: method to composite the images, but also free to render them via NSImageView instances, if that will make things easier. My initial instinct was to setup NSTrackingArea's for each NSImage instance but wanted to ensure I wasn't missing something obvious.
Possibly a better way to do this would be to set up the images as Core Animation layers. You can then very easily make the images pop up/enlarge in an animated fashion without having to write the drawing code to do it. Performance will be a lot better also.
As for the mouse tracking, NSTrackingArea
is a good way to go.
精彩评论