Select list items with Command + number.
This commit is contained in:
@@ -34,6 +34,8 @@ final class EditableNSTextField: NSTextField {
|
||||
if NSApp.sendAction(#selector(NSResponder.selectAll(_:)), to: nil, from: self) {
|
||||
return true
|
||||
}
|
||||
} else if isNumericalCode(key) { // Ignore Command + {1-9}.
|
||||
return true
|
||||
}
|
||||
} else if modsContains(keys: OSCmd | OSShift, in: modifiers) {
|
||||
if key == kVK_ANSI_Z {
|
||||
|
||||
@@ -11,6 +11,10 @@ func modsContains(keys: UInt, in modifiers: UInt) -> Bool {
|
||||
return (modifiers & keys) == keys && ((modifiers ^ keys) & OSMods) == 0
|
||||
}
|
||||
|
||||
func isNumericalCode(_ key: UInt16) -> Bool {
|
||||
return (key == kVK_ANSI_1 || key == kVK_ANSI_2 || key == kVK_ANSI_3 || key == kVK_ANSI_4 || key == kVK_ANSI_5 || key == kVK_ANSI_6 || key == kVK_ANSI_7 || key == kVK_ANSI_8 || key == kVK_ANSI_9)
|
||||
}
|
||||
|
||||
func modsContainsNone(in modifiers: UInt) -> Bool {
|
||||
return (modifiers & OSMods) == 0
|
||||
}
|
||||
|
||||
@@ -192,6 +192,16 @@ class SearchViewController: NSViewController, NSTextFieldDelegate, NSPopoverDele
|
||||
modsContainsNone(in: modifiers) && key == kVK_DownArrow
|
||||
{
|
||||
controller.programsTableViewSelection += 1
|
||||
} else if modsContains(keys: OSCmd, in: modifiers) && isNumericalCode(key) {
|
||||
if key == kVK_ANSI_1 { controller.programsTableViewSelection = 0 }
|
||||
if key == kVK_ANSI_2 { controller.programsTableViewSelection = 1 }
|
||||
if key == kVK_ANSI_3 { controller.programsTableViewSelection = 2 }
|
||||
if key == kVK_ANSI_4 { controller.programsTableViewSelection = 3 }
|
||||
if key == kVK_ANSI_5 { controller.programsTableViewSelection = 4 }
|
||||
if key == kVK_ANSI_6 { controller.programsTableViewSelection = 5 }
|
||||
if key == kVK_ANSI_7 { controller.programsTableViewSelection = 6 }
|
||||
if key == kVK_ANSI_8 { controller.programsTableViewSelection = 7 }
|
||||
if key == kVK_ANSI_9 { controller.programsTableViewSelection = 8 }
|
||||
}
|
||||
|
||||
if controller.programsTableViewSelection > controller.listIndex-1 {
|
||||
|
||||
Reference in New Issue
Block a user