Look at the simple app screenshot below. There is a text field and a segmented control. There are three bindings in play:
- textfield
value
binding goes toNSUserDefaultsController
values.TextValue
- textfield
alignment
binding goesNSUserDefaultsController
values.Alignment
- segmented control
selectedIndex
binding goes toNSUserDefaultsController
values.Alignment
So the segmented control controls the text field's alignment.
Problem: When the text field has first responder, if you click on the segmented control to change the alignment, the text field 1.) throws out the value being edited and reverts to the last bound value, 2.) does not update its alignment, 3.) remains first responder.
Expected behavior would be: when you change the segmented control value the text field resigns first responder, commits the value in the UI to user defaults, and updates its alignment. How can this be done?
You’ve hit a bug and should report a RADAR. There have been many bugs with textfields and bindings when you’re editing a textfield, it’s not an area the engineers focused on originally.
You don’t even need to bind the textField’s value to replicate this, you can just bind the alignment of the textField.