Reading time: 1 min
This recipe shows how to navigate from one text field to another using keyboard buttons in SwiftUI by combining
Reading time: 2 min
Detecting if a text field gained or lost focus is not entirely straightforward in SwiftUI.
TextField constructor has a parameter named
onEditingChanged, but it triggers only when the user taps the return key in the virtual keyboard, not when the focus is actually lost.
SecureField doesn't have such a parameter, and there's no way to know if the user is interacting with the view!