首页 > 解决方案 > Ordering of events from addGlobalMonitorForEvents

问题描述

I am trying to monitor mouse click events like so:

clickMonitor = NSEvent.addGlobalMonitorForEvents(
  matching: [.leftMouseDown, .rightMouseDown, .leftMouseUp, .rightMouseUp]) {
    [unowned self] event in
   ...

However, it appears that my events are coming in out of order. For instance, often for a double-click, I get two .leftMouseDown events (with counts 1 and 2) before I get either .leftMouseUp event.

Are there any guarantees to ensure the ordering that these events will come in? If not, is there any mechanism for ordering them?

标签: swiftmacoscocoansevent

解决方案


推荐阅读