开发者

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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜