feat: navigate launcher results with control-j and control-k
This commit is contained in:
@@ -32,6 +32,7 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
|
||||
super.init(window: window)
|
||||
configureContent(in: window)
|
||||
window.delegate = self
|
||||
window.navigateSelection = { [weak self] offset in self?.moveSelection(by: offset) }
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
@@ -390,6 +391,24 @@ private final class ApplicationTableView: NSTableView {
|
||||
private final class LauncherPanel: NSPanel {
|
||||
override var canBecomeKey: Bool { true }
|
||||
override var canBecomeMain: Bool { true }
|
||||
var navigateSelection: ((Int) -> Void)?
|
||||
|
||||
override func sendEvent(_ event: NSEvent) {
|
||||
if event.type == .keyDown, attachedSheet == nil,
|
||||
event.modifierFlags.intersection([.control, .command, .option, .shift]) == .control {
|
||||
switch event.charactersIgnoringModifiers?.lowercased() {
|
||||
case "j":
|
||||
navigateSelection?(1)
|
||||
return
|
||||
case "k":
|
||||
navigateSelection?(-1)
|
||||
return
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
super.sendEvent(event)
|
||||
}
|
||||
|
||||
override func performClose(_ sender: Any?) {
|
||||
close()
|
||||
|
||||
Reference in New Issue
Block a user