Picker keyboard focus
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user