I have a subclass of NSView that is able to track the mouse.
In the mouseMoved method I can determine the mouse position from the NSEvent.
Now I want to draw something at that position, however the coordinate system seems to have shifted. In a normal NSView subclass, you can only draw within the view itself and the origin of the coordinate system corresponds to the lower left corner of the NSView. When I do any drawing in the mouseMoved, it's relative to the lower left corner of the window.
Any trick/idea as to how I can find out where my NSView is, or to restrict drawing in the manner accustomed to the NSView subclass?
Thanks.
EDIT:
Another case of formulating the question to find the answer, although it's an inefficient one.
Adding a variable to class that holds a NSPoint currentLocation.
In mouseMoved: set the currentLocation and set needsDisplay: to yes for the view.
But this causes the entire view to redraw, which is unnecessary. Only a small portion needs to redraw itself.
In the mouseMoved method I can determine the mouse position from the NSEvent.
Now I want to draw something at that position, however the coordinate system seems to have shifted. In a normal NSView subclass, you can only draw within the view itself and the origin of the coordinate system corresponds to the lower left corner of the NSView. When I do any drawing in the mouseMoved, it's relative to the lower left corner of the window.
Any trick/idea as to how I can find out where my NSView is, or to restrict drawing in the manner accustomed to the NSView subclass?
Thanks.
EDIT:
Another case of formulating the question to find the answer, although it's an inefficient one.
Adding a variable to class that holds a NSPoint currentLocation.
In mouseMoved: set the currentLocation and set needsDisplay: to yes for the view.
But this causes the entire view to redraw, which is unnecessary. Only a small portion needs to redraw itself.