XCode 12 Swift 5 capturing edits in NSTextFields before closing window

33 Views Asked by At

I am rewriting an old Objective-C application using Swift, and am trying to follow the latest conventions, including Storyboards instead of NIB/XIB files.

I have a preferences window with a number of different text fields. I have actions that run when a field is exited. Bottom line: any edits in a text field that is still selected are lost when the window is closed.

The fields are embedded in a NSTabView... If I select a field and switch to a different tab, that field is exited and the appropriate function is triggered. However, if I close the window, nothing happens. If the user made changes in a particular field and closed the window, those changes are lost. That seems very non-Mac like.

So, is there a way to deselect any selected text fields in a window as that window is closing?

This feels like it should be simple, but I can't figure it out.

0

There are 0 best solutions below