How can I detect when a TextField is tapped? (SwiftUI on MacOS)
import SwiftUI
struct ContentView: View {
@State var field: String = "TextField"
var body: some View {
TextField("Fill in Text", text: $field)
.onTapGesture {
print("Textfield pressed")
}
}
}
When the TextField is tapped it doesn't print "Textfield pressed". I'm guessing this is because the tap is picked up by the TextField before it can be detected by the Textfield gesture.
onEditingChanged
and nothing else. If you only tap on the textfield this will not fire. – Offcenter