Reputation: 16430
I have an NSTextField
with value bound to a Shared User Default Controller
The NSUserDefault value change only when user press "Enter" ok keyboard.
I'd like to produce the same effect (simulate the return hit on a specific field) when user push a button on the UI.
Is it possible ?
Upvotes: 0
Views: 307
Reputation: 15003
In your button's action, do this:
[[NSUserDefaultsController sharedUserDefaultsController] commitEditing]
Upvotes: 1
Reputation: 104082
In your bindings, you can check the "Continuously Updates Value" box to have the user defaults update as you type, so if your button method just checks the value, it will always be up to date. A more general solution to update the value of a text field is to have the window make something other than the text field the first responder (this is what happens when you tab out of a text field to the next responder). You can do this with:
[window makeFirstResponder:window];
Upvotes: 1