mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: added keyboard command to the settings window. cmd+c/cmd+w - will close the window. cmd+m - will miniaturize the window (#613)
This commit is contained in:
committed by
GitHub
parent
20e2d6a311
commit
fe170b77ef
@@ -49,6 +49,20 @@ class SettingsWindow: NSWindow, NSWindowDelegate {
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
}
|
||||
|
||||
override func performKeyEquivalent(with event: NSEvent) -> Bool {
|
||||
if event.type == NSEvent.EventType.keyDown && event.modifierFlags.contains(.command) {
|
||||
if event.keyCode == 12 || event.keyCode == 13 {
|
||||
self.setIsVisible(false)
|
||||
return true
|
||||
} else if event.keyCode == 46 {
|
||||
self.miniaturize(event)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return super.performKeyEquivalent(with: event)
|
||||
}
|
||||
|
||||
@objc private func toggleSettingsHandler(_ notification: Notification) {
|
||||
if !self.isVisible {
|
||||
self.setIsVisible(true)
|
||||
|
||||
Reference in New Issue
Block a user