Feature: Support command+w to close dashboard

This commit is contained in:
yicheng 2019-02-13 11:19:32 +08:00
parent 71ddd619e4
commit 16c087a56d

View File

@ -49,6 +49,11 @@ class ClashWebViewContoller: NSViewController {
}.disposed(by: disposeBag)
loadWebRecourses()
NSEvent.addLocalMonitorForEvents(matching: .keyDown) {[weak self] in
self?.keyDown(with: $0)
return $0
}
}
func loadWebRecourses() {
@ -83,6 +88,15 @@ class ClashWebViewContoller: NSViewController {
NSApp.setActivationPolicy(.accessory)
}
override func keyDown(with event: NSEvent) {
switch event.modifierFlags.intersection(.deviceIndependentFlagsMask) {
case [.command] where event.characters == "w":
self.view.window?.close()
default:
break
}
}