Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSView mouse tracking

I'm facing a strange behavior with Cocoa NSView on Mac OS X.

I've a custom NSView in a NSView container, this custom NSView tracks mouse movements, clicks, and has a tooltip. When I add a NSView above the described view, I can still see the tooltips even if the view with the tooltip is under, behind and not visible.

I'm pretty sure that I misunderstood something in the event handling chain. Any help is really appreciated!

like image 639
SlowTree Avatar asked Feb 10 '12 09:02

SlowTree


People also ask

How do I track my mouse movement?

A mouse recorder is a tool that records mouse movements on a website. So when someone visits your site, a mouse recorder records all their interactions on your site – mouse movements as well as clicks.

What does tracking mean on a mouse?

Mouse tracking (also known as cursor tracking) is the use of software to collect users' mouse cursor positions on the computer.

How do I find my mouse position in coordinates?

On this page, press and hold the 'Alt' key, then press the 'Z' key to toggle the X/Y coordinates layer on and off. For Firefox, you'll need to hold down the 'Shift' and 'Alt' keys simultaneously, along with the 'z' accesskey. This nifty functionality is achieved using Access Keys.


1 Answers

The core issue is that you are not supposed to have overlapping views in Cocoa. Or at least, the behavior then becomes undefined. A view can be a subview of another view, but not simply a sibling within the bounds of the other view.

However, one way to solve your particular problem is to make the view underneath hidden, using the setHidden: method.

like image 79
charles Avatar answered Oct 19 '22 03:10

charles