fix: dismiss active launcher window on Escape
This commit is contained in:
@@ -158,9 +158,13 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
|
||||
|
||||
func dismiss(restoringFocus: Bool = true) {
|
||||
guard !restoringFocus || (!isLaunching && window?.attachedSheet == nil) else { return }
|
||||
if let review = uninstallReview { review.goBack(); return }
|
||||
if launcherFrameBeforeReview != nil {
|
||||
guard uninstallReview?.canClose != false else { return }
|
||||
pendingPresentation = { [weak self] in self?.dismiss(restoringFocus: restoringFocus) }
|
||||
uninstallReview?.goBack()
|
||||
return
|
||||
}
|
||||
closeCommand()
|
||||
guard launcherFrameBeforeReview == nil else { return }
|
||||
actions.close(animated: false)
|
||||
alignmentGuides?.end()
|
||||
let previous = previousApplication
|
||||
@@ -257,7 +261,7 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
|
||||
commandBack.isBordered = false
|
||||
commandBack.contentTintColor = SunsetPalette.secondaryText
|
||||
commandBack.setAccessibilityLabel("Back to applications")
|
||||
commandBack.toolTip = "Back to applications (Escape)"
|
||||
commandBack.toolTip = "Back to applications"
|
||||
commandBack.isHidden = true
|
||||
NSLayoutConstraint.activate([
|
||||
commandBack.widthAnchor.constraint(equalToConstant: IconStyle.applicationSize(for: searchFont)),
|
||||
@@ -478,10 +482,13 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
|
||||
}
|
||||
|
||||
func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
|
||||
if commandSelector == #selector(NSResponder.cancelOperation(_:)) {
|
||||
dismiss()
|
||||
return true
|
||||
}
|
||||
if let emojiPicker { return emojiPicker.handle(commandSelector) }
|
||||
if let translation {
|
||||
if commandSelector == #selector(NSResponder.insertNewline(_:)) { translation.translate(); return true }
|
||||
if commandSelector == #selector(NSResponder.cancelOperation(_:)) { translation.goBack(); return true }
|
||||
return false
|
||||
}
|
||||
switch commandSelector {
|
||||
@@ -491,8 +498,6 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
|
||||
moveSelection(by: -1)
|
||||
case #selector(NSResponder.insertNewline(_:)):
|
||||
openSelection()
|
||||
case #selector(NSResponder.cancelOperation(_:)):
|
||||
dismiss()
|
||||
default:
|
||||
return false
|
||||
}
|
||||
@@ -1201,6 +1206,11 @@ final class LauncherPanel: NSPanel {
|
||||
}
|
||||
|
||||
override func sendEvent(_ event: NSEvent) {
|
||||
if event.type == .keyDown, event.keyCode == 53, attachedSheet == nil,
|
||||
event.modifierFlags.intersection([.command, .control, .option, .shift]).isEmpty {
|
||||
cancelOperation(nil)
|
||||
return
|
||||
}
|
||||
let eligible = numberShortcutsEligible
|
||||
if event.type == .flagsChanged || (event.type == .keyUp && event.keyCode == 49) {
|
||||
reevaluateNumberHints(modifierFlags: event.modifierFlags, eligible: eligible, at: event.timestamp)
|
||||
@@ -1233,6 +1243,10 @@ final class LauncherPanel: NSPanel {
|
||||
}
|
||||
}
|
||||
|
||||
override func cancelOperation(_ sender: Any?) {
|
||||
dismiss?()
|
||||
}
|
||||
|
||||
override func performClose(_ sender: Any?) {
|
||||
dismiss?()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user