I need to find if the mouse position is inside an NSView’s rect.
I’d use NSPointInRect(point, rect), but I’d need to convert the rect coordinates to screen coordinates and I’m not sure how. Any help would be much appreciated!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use NSView’s convertPoint:fromView: method with fromView as nil to covert a point in window coordinates to a view’s coordinate system.
After converting the mouse point to the view’s coordinate system, I would use NSView’s mouse:inRect: method instead of NSPointInRect as the former also accounts for flipped coordinate systems.
Alternatively, you could use a Tracking Area Object.