Picker keyboard focus

This commit is contained in:
Ian Gulliver
2026-10-21 10:13:31 -07:00
parent 9afe016b06
commit 1ab0ebad9f
2 changed files with 17 additions and 2 deletions
+5 -1
View File
@@ -192,7 +192,11 @@ final class Overlays {
} }
if image == nil, !marked, let switcher { if image == nil, !marked, let switcher {
if code == 48 { if code == 48 {
switcher.move(flags.contains(.shift) ? -1 : 1) switcher.inList.toggle()
return true
}
if switcher.inList && (code == 125 || code == 126) {
switcher.move(code == 125 ? 1 : -1)
return true return true
} }
if enter && !flags.contains(.shift) { if enter && !flags.contains(.shift) {
+12 -1
View File
@@ -77,7 +77,8 @@ private let shortcuts: [(String, [(String, String)])] = [
("Esc", "Close the switcher or a dialog"), ("Esc", "Close the switcher or a dialog"),
]), ]),
("Task switcher", [ ("Task switcher", [
("Tab / Shift+Tab", "Move the highlight"), ("Tab", "Switch between the text and the list"),
("↑ ↓", "Move the highlight, in the list"),
("Enter", "Pick the highlighted row"), ("Enter", "Pick the highlighted row"),
("Shift+Enter", "New line in the first message"), ("Shift+Enter", "New line in the first message"),
("name: message", "Start the task in the project whose name starts with name"), ("name: message", "Start the task in the project whose name starts with name"),
@@ -153,6 +154,7 @@ final class SwitcherModel {
let imageKey = "switcher:\(UUID().uuidString)" let imageKey = "switcher:\(UUID().uuidString)"
var text = "" var text = ""
var selected = 0 var selected = 0
var inList = false
var workflows: [WorkflowSummary] = [] var workflows: [WorkflowSummary] = []
init(store: Store, overlays: Overlays, anchor: CGRect) { init(store: Store, overlays: Overlays, anchor: CGRect) {
@@ -389,6 +391,7 @@ private struct SwitcherBox: View {
.padding(.vertical, 6) .padding(.vertical, 6)
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
.background(i == selected ? Palette.accentTint : .clear, in: RoundedRectangle(cornerRadius: 6)) .background(i == selected ? Palette.accentTint : .clear, in: RoundedRectangle(cornerRadius: 6))
.overlay(RoundedRectangle(cornerRadius: 6).stroke(i == selected && model.inList ? Palette.accent : .clear))
.contentShape(Rectangle()) .contentShape(Rectangle())
.onTapGesture { .onTapGesture {
model.pick(row) model.pick(row)
@@ -421,6 +424,14 @@ private struct SwitcherBox: View {
} }
} }
} }
.onChange(of: model.inList) {
focused = !model.inList
}
.onChange(of: focused) {
if focused {
model.inList = false
}
}
} }
private var editor: some View { private var editor: some View {