I have a TextField in my toolbar that I use for a search function. I want to trigger the search by hitting the "return" key in this field. But if I do it in onCommit, the search also gets triggered when the user un-focuses the field.
Is there a way to respond to just the "return" key?
Is there a way to respond to just the "return" key?
Code Block TextField("Search", text: $searchQuery) { editing in print("onEditingChanged \(editing)") } onCommit: { // Problem: this is triggered by both // 1. Return key // 2. Losing focus searchModel.startSearch(query: searchQuery) }