PopoverPanel no longer handles key equivalents.
This commit is contained in:
+38
-16
@@ -1,5 +1,6 @@
|
||||
import Cocoa
|
||||
import ServiceManagement
|
||||
import OSLog
|
||||
|
||||
fileprivate enum Metrics {
|
||||
static let contentMinWidth = 400.0
|
||||
@@ -11,6 +12,11 @@ fileprivate enum Metrics {
|
||||
}
|
||||
|
||||
class CmdViewController: NSViewController {
|
||||
fileprivate static let logger = Logger(
|
||||
subsystem: Bundle.main.bundleIdentifier!,
|
||||
category: String(describing: CmdViewController.self)
|
||||
)
|
||||
|
||||
private weak var cmdFile: CmdFile?
|
||||
private var timer: DispatchSourceTimer?
|
||||
private var keyboardEvents: EventMonitor?
|
||||
@@ -346,6 +352,12 @@ class CmdViewController: NSViewController {
|
||||
|
||||
private func setupKeyEvents() {
|
||||
keyboardEvents = LocalEventMonitor(mask: [.flagsChanged, .keyDown], handler: { [weak self] event in
|
||||
let modifiers = event.modifierFlags.rawValue
|
||||
let command = NSEvent.ModifierFlags.command.rawValue
|
||||
let shift = NSEvent.ModifierFlags.shift.rawValue
|
||||
let control = NSEvent.ModifierFlags.control.rawValue
|
||||
let option = NSEvent.ModifierFlags.option.rawValue
|
||||
|
||||
if event.modifierFlags.contains(.shift) {
|
||||
self?.reloadButton.image = systemImage("arrow.clockwise.circle.fill", .title2, .large, .init(paletteColors: [.white, .systemCyan]))
|
||||
self?.reloadButton.action = #selector(self?.reloadWidgets)
|
||||
@@ -356,24 +368,34 @@ class CmdViewController: NSViewController {
|
||||
self?.reloadButton.toolTip = "Reload Current"
|
||||
}
|
||||
|
||||
if event.modifierFlags.contains(.command) && event.keyCode == 15 { // r
|
||||
self?.reloadWidget()
|
||||
}
|
||||
|
||||
if event.modifierFlags.contains(.shift) && event.modifierFlags.contains(.command) && event.keyCode == 15 { // r
|
||||
self?.reloadWidgets()
|
||||
}
|
||||
|
||||
if (event.modifierFlags.contains(.command) && event.keyCode == 13) || event.keyCode == 12 || event.keyCode == 53 { // w, q, esc
|
||||
self?.view.superview?.window?.resignKey()
|
||||
}
|
||||
|
||||
if event.modifierFlags.contains(.command) && event.keyCode == 12 { // q
|
||||
// NOTE: Standalone keys should go last!
|
||||
if (modifiers & command) == command,
|
||||
(modifiers & (control | shift | option)) == 0,
|
||||
event.keyCode == 12 // Q
|
||||
{
|
||||
self?.terminateApp()
|
||||
}
|
||||
|
||||
if event.modifierFlags.contains(.command) && event.keyCode == 8 { // c
|
||||
} else if (modifiers & command) == command,
|
||||
(modifiers & (control | shift | option)) == 0,
|
||||
event.keyCode == 13 // W
|
||||
{
|
||||
self?.view.superview?.window?.resignKey()
|
||||
} else if (modifiers & command) == command,
|
||||
(modifiers & (control | shift | option)) == 0,
|
||||
event.keyCode == 15 // R
|
||||
{
|
||||
self?.reloadWidget()
|
||||
} else if (modifiers & (command & shift)) == command & shift,
|
||||
(modifiers & (control | option)) == 0,
|
||||
event.keyCode == 15 // R
|
||||
{
|
||||
self?.reloadWidgets()
|
||||
} else if (modifiers & command) == command,
|
||||
(modifiers & (control | shift | option)) == 0,
|
||||
event.keyCode == 8 // C
|
||||
{
|
||||
self?.textLabel.currentEditor()?.copy(nil)
|
||||
} else if event.keyCode == 12 || event.keyCode == 53 { // Q, ESC
|
||||
self?.view.superview?.window?.resignKey()
|
||||
}
|
||||
|
||||
return event
|
||||
|
||||
Reference in New Issue
Block a user