Fix picker arrows and Escape being lost to the window
This commit is contained in:
@@ -60,6 +60,8 @@ final class Overlays {
|
||||
@ObservationIgnored weak var window: NSWindow?
|
||||
@ObservationIgnored private var monitor: Any?
|
||||
@ObservationIgnored private var mouseMonitor: Any?
|
||||
@ObservationIgnored private var holders = 0
|
||||
@ObservationIgnored private var ctrl: @MainActor (String) -> Bool = { _ in false }
|
||||
|
||||
var isOpen: Bool {
|
||||
!alerts.isEmpty || image != nil || menu != nil || modal != nil || switcher != nil
|
||||
@@ -131,6 +133,8 @@ final class Overlays {
|
||||
}
|
||||
|
||||
func install(_ ctrl: @escaping @MainActor (String) -> Bool) {
|
||||
holders += 1
|
||||
self.ctrl = ctrl
|
||||
if monitor != nil {
|
||||
return
|
||||
}
|
||||
@@ -143,7 +147,7 @@ final class Overlays {
|
||||
guard let self, let window = self.window, win == ObjectIdentifier(window) else {
|
||||
return false
|
||||
}
|
||||
return self.key(event, code, flags, chars, ctrl)
|
||||
return self.key(event, code, flags, chars)
|
||||
}
|
||||
return taken ? nil : event
|
||||
}
|
||||
@@ -158,7 +162,7 @@ final class Overlays {
|
||||
}
|
||||
}
|
||||
|
||||
private func key(_ event: NSEvent, _ code: UInt16, _ flags: NSEvent.ModifierFlags, _ chars: String, _ ctrl: @MainActor (String) -> Bool) -> Bool {
|
||||
private func key(_ event: NSEvent, _ code: UInt16, _ flags: NSEvent.ModifierFlags, _ chars: String) -> Bool {
|
||||
if !dialogOpen && flags.contains(.control) && !flags.contains(.command) && goKeys.contains(chars) {
|
||||
return ctrl(chars)
|
||||
}
|
||||
@@ -213,6 +217,11 @@ final class Overlays {
|
||||
}
|
||||
|
||||
func uninstall() {
|
||||
holders -= 1
|
||||
if holders > 0 {
|
||||
return
|
||||
}
|
||||
ctrl = { _ in false }
|
||||
if let monitor {
|
||||
NSEvent.removeMonitor(monitor)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user