| | |
| | | |
| | | let start = Date() |
| | | let longPressDuration: TimeInterval = 0.35 |
| | | let maxTrackingDuration: TimeInterval = 8 |
| | | var reorderActive = false |
| | | var finished = false |
| | | |
| | | while !finished { |
| | | guard let window, |
| | | window.isVisible, |
| | | NSApp.isActive, |
| | | Date().timeIntervalSince(start) < maxTrackingDuration |
| | | else { |
| | | if reorderActive { |
| | | onReorderEnded() |
| | | } |
| | | break |
| | | } |
| | | |
| | | if !reorderActive && Date().timeIntervalSince(start) >= longPressDuration { |
| | | reorderActive = true |
| | | onReorderBegan(item.id) |
| | | } |
| | | |
| | | let nextEvent = window?.nextEvent( |
| | | if NSEvent.pressedMouseButtons & (1 << 0) == 0 { |
| | | if reorderActive { |
| | | onReorderEnded() |
| | | } else { |
| | | onActivate(item.id) |
| | | } |
| | | break |
| | | } |
| | | |
| | | let nextEvent = window.nextEvent( |
| | | matching: [.leftMouseDragged, .leftMouseUp], |
| | | until: Date().addingTimeInterval(0.04), |
| | | inMode: .eventTracking, |