Global Mouse Moved Events in Cocoa

前端 未结 3 1682
感动是毒
感动是毒 2020-12-25 09:55

Is there a way to register for global mouse moved events in Cocoa? I was able to register for the events using Carbon\'s InstallEventHandler(), but would prefer

3条回答
  •  自闭症患者
    2020-12-25 10:16

    In SnowLeopard there is a new class method on NSEvent which does exactly what you want: + (id)addGlobalMonitorForEventsMatchingMask:(NSEventMask)mask handler:(void (^)(NSEvent*))block. You’ll want mask = NSMouseMovedMask.

提交回复
热议问题