Sorig
Sorig

Reputation: 1211

Globally monitoring NSMouseMoved returns NSMouseUp

I'm trying to register the NSMouseMoved event globally using this line of code:

[NSEvent addGlobalMonitorForEventsMatchingMask:NSMouseMoved handler:mouseMovedBlock];

However, my mouseMovedBlock only gets called when the mouse gets clicked and not when the mouse is moved. I tried detecting the type of the NSEvent and it returns NSMouseUp, which doesn't really make any sense.

Why is my program acting so strange / what did I miss?

Upvotes: 3

Views: 467

Answers (1)

Sorig
Sorig

Reputation: 1211

Turns out it was a simple mistake. I just changed "NSMouseMoved" to "NSMouseMovedMask". I simply forgot that it needed to be an event mask instead of a normal event type.

Upvotes: 6

Related Questions