NSEventMask.AnyEventMask doesn't work with global monitor
Originator: | keithbsmiley | ||
Number: | rdar://27516289 | Date Originated: | 24-Jul-2016 13:37 |
Status: | Open | Resolved: | |
Product: | OS X SDK | Product Version: | OS X 10.11.5 |
Classification: | Other Bug | Reproducible: | Always |
Summary: Currently if you pass `NSEventMask.AnyEventMask` to `NSEvent.addGlobalMonitorForEventsMatchingMask`, the callback is never fired. Steps to Reproduce: 1) Register a global event monitor with `NSEvent.addGlobalMonitorForEventsMatchingMask(.AnyEventMask) { print($0) } Expected Results: `print` is fired when every single event in the system, meaning mouse moves, and keyboard events Actual Results: The callback is never fired. Version: OS X 10.11.5 Notes: You can work around this by assigning an event mask defined as: ``` NSEventMask(rawValue: 0xfffffffffffffff) ``` Instead. Here's some sample code that shows this issue (uncomment as necessary): ``` import AppKit // This one works let mask = NSEventMask(rawValue: 0xfffffffffffffff) // This one does not // let mask = NSEventMask.AnyEventMask NSEvent.addGlobalMonitorForEventsMatchingMask(mask) { event in print(event) } let application = NSApplication.sharedApplication() application.run() ```
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!