How to force an NSTextField to accept the text?
I have an NSTextField in a Preferences panel. It provides a field to enter a url in. However, if the user closes the Preferences panel after editing the text in the field, the new val开发者_如何学JAVAue does not get propagated to the User Defaults. This only happens after the user explicitly does Enter or Tab.
This kind of makes the whole approach useless, it seems to me, so I guess I must be doing something wrong?I fix this by setting the firstResponder to nil when the window closes.
[[self window] makeFirstResponder:nil];
精彩评论