Skip to content

Commit

Permalink
Merge pull request #176 from nhnicwaller/tabs
Browse files Browse the repository at this point in the history
enable tabbing through script list
  • Loading branch information
IvanMathy authored Sep 20, 2020
2 parents 5a0dcea + 9cb2312 commit 4f45d92
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Boop/Boop/Controllers/PopoverViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class PopoverViewController: NSViewController {
var didSomething = false

// Key codes:
let kVKTab = 0x30
// 125 is down arrow
// 126 is up
// 53 is escape
Expand All @@ -72,9 +73,20 @@ class PopoverViewController: NSViewController {

didSomething = true
}

let window = self.view.window

if theEvent.keyCode == kVKTab && self.enabled {
if window?.firstResponder is NSTextView &&
(window?.firstResponder as! NSTextView).delegate is SearchField {
let offset = theEvent.modifierFlags.contains(.shift) ? -1 : 1
let newSel = IndexSet([self.tableView.selectedRow + offset])
self.tableView.selectRowIndexes(newSel, byExtendingSelection: false)
self.tableView.scrollRowToVisible(self.tableView.selectedRow)
}
didSomething = true // prevent tabbing back into text document
}

if window?.firstResponder is NSTextView &&
(window?.firstResponder as! NSTextView).delegate is SearchField &&
theEvent.keyCode == 125 { // DOWN
Expand Down

0 comments on commit 4f45d92

Please sign in to comment.