Imagine that I have 6 TextFields arranged in a grid with 3 columns and 2 rows. We'll refer to them by their X,Y position in this grid, starting with 1,1 in the upper left TextField, and 3,2 in the lower right corner.
When I run this program, I put the cursor in TextField 1,1 and enter a value. I hit tab and the cursor goes to 2,1; then to 3,1; then to 1,2; then 2,2; and finally to 3,2.
The cursor is marching horizontally across the first row, then the second, and so on.
I need to change that order, though.
I need it to march down column 1, before moving to column 2, and then on to column 3.
In Cocoa programming, you can specify the order using nextKeyView.
Is there anything similar in SwiftUI?
I was hoping I could group them in VStacks like below and get the behavior I wanted, but it doesn't work. I also tried putting the column-pairs in Group{...} but it doesn't work.
struct ContentView: View {
@State private var oneone = ""
@State private var onetwo = ""
@State private var twoone = ""
@State private var twotwo = ""
@State private var threeone = ""
@State private var threetwo = ""
var body: some View {
HStack {
VStack {
TextField("1,1", text: $oneone)
TextField("1,2", text: $onetwo)
}
VStack {
TextField("2,1", text: $twoone)
TextField("2,2", text: $twotwo)
}
VStack {
TextField("3,1", text: $threeone)
TextField("3,2", text: $threetwo)
}
}
}
}