From 1ab0ebad9ff7dcceb221d049e02779432cdf2346 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Wed, 21 Oct 2026 10:13:31 -0700 Subject: [PATCH] Picker keyboard focus --- mac/Sources/Byre/Dialogs.swift | 6 +++++- mac/Sources/Byre/Switcher.swift | 13 ++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/mac/Sources/Byre/Dialogs.swift b/mac/Sources/Byre/Dialogs.swift index 9a626b3..de916e1 100644 --- a/mac/Sources/Byre/Dialogs.swift +++ b/mac/Sources/Byre/Dialogs.swift @@ -192,7 +192,11 @@ final class Overlays { } if image == nil, !marked, let switcher { 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 } if enter && !flags.contains(.shift) { diff --git a/mac/Sources/Byre/Switcher.swift b/mac/Sources/Byre/Switcher.swift index aeaab4c..5adf868 100644 --- a/mac/Sources/Byre/Switcher.swift +++ b/mac/Sources/Byre/Switcher.swift @@ -77,7 +77,8 @@ private let shortcuts: [(String, [(String, String)])] = [ ("Esc", "Close the switcher or a dialog"), ]), ("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"), ("Shift+Enter", "New line in the first message"), ("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)" var text = "" var selected = 0 + var inList = false var workflows: [WorkflowSummary] = [] init(store: Store, overlays: Overlays, anchor: CGRect) { @@ -389,6 +391,7 @@ private struct SwitcherBox: View { .padding(.vertical, 6) .frame(maxWidth: .infinity, alignment: .leading) .background(i == selected ? Palette.accentTint : .clear, in: RoundedRectangle(cornerRadius: 6)) + .overlay(RoundedRectangle(cornerRadius: 6).stroke(i == selected && model.inList ? Palette.accent : .clear)) .contentShape(Rectangle()) .onTapGesture { 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 {