title: How can I remove Textfield focus when I press return or click outside Textfield? (SwiftUI, MacOS)
body: <p>How can I remove Textfield focus when I press return or click outside Textfield?
  Note that this is SwiftUI on <strong>MacOS</strong>.</p>
  
  <p>If I do this:</p>
  
  <pre><code>import SwiftUI
  
  struct ContentView: View {
    @State var field1: String = "This is the Text Field View"
  
    var body: some View {
      VStack{
        Button("Press") {
          print("Button Pressed")
        }
  
        TextField("Fill in Text", text: Binding(
          get: { print("get") ; return self.field1 },
          set: { print("set") ; self.field1 = $0 }
          )
        )
      }
    }
  }
  </code></pre>
  
  <p>then click into the TextField and edit it then click on the Button the TextField does not lose focus.  How can I make it exit editing mode and lose focus.</p>
  
  <p>I would also like to lose focus from the TextField if I press Return.
  I used the Binding initialiser with get and set because I thought I could somehow intercept keypresses and detect the 'Return' character but this doesn't work.</p>
  
  <p>Any help appreciated :-)</p>