UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Changing First Responder Order for TextFields

Forums > SwiftUI

I am working on a crossword app.

I have a SquareView that contains a Text and TextField, to show the number and letter for a particular square.

A 2D array of those SquareViews forms the grid of the puzzle.

I can navigate back and forth horizontally through the TextFields using the tab key, and all the highlighting works (current square yellow, adjacent answer squares blue, all others white or black).

My problem arises when I want to toggle navigation, to move vertically. I thought that the order in which TextFields were navigated depended on the order in which they were added, so I toggled between a VStack of HStacks (across clues, running horizontally) and HStack of VStacks (for down clues, running vertically). Nope. SwiftUI always moves from left-to-right, top-to-bottom. How can I change this? I learned from this forum about Introspect, so I can access each TextField's underlying UITextField and change ... it's color 😀, but that's not what I need. I need to be able to change order in which first responders are chosen.

Any assistance would be most welcome!

3      

I solved the problem by resorting to UIKit.

3      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.