Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
Why aren't my tracking rects working?
Q:
I'm trying to implement tracking rectangles so that I can recieve -mouseEntered:
and -mouseExited:
messages and provide visual feedback to the user. I've sent my view an -addTrackingRect:owner:userData:assumeInside:
message, but it seems to have no effect.
A: This symptom usually results from trying to set tracking rectangles before your view has been added to a window.
Although NSView implements the -addTrackingRect:owner:userData:assumeInside:
method, the list of tracking rectangles is kept by the window, not the view. When your -initWithFrame:
method is executed, your view is not yet associated with any window, so the view can't actually set any tracking rects.
A better place to send your -addTrackingRect:
.. messages is in a -viewDidMoveToWindow:
or -awakefromNib
method.
Document Revision History
Date | Notes |
---|---|
2014-03-06 | Describes a common mistake in setting up cursor-tracking rectangles. |
2004-12-02 | New document that describes a common mistake in setting up cursor-tracking rectangles. |
Copyright © 2004 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2004-12-02