完成后辞职 NSSearchField 的第一响应者的干净方法?
在我的应用程序中,我有一个绑定到数组控制器的 NSSearchField,该数组控制器在用户输入时执行搜索。
问题是搜索字段一旦收到第一响应者状态就永远不会放弃它。
当用户按 Enter
或在搜索字段之外单击时,放弃第一响应者状态的最简洁方法是什么?如果可能的话,我更愿意在 Interface Builder 中做尽可能多的工作。
In my application I have an NSSearchField that is bound to an arraycontroller which performs searches as the user types.
The problem is that the search field never resigns firstresponder-status once it receives it.
What would be the cleanest way of resigning firstresponder status when the user presses Enter
or clicks outside of the search field? If possible I would prefer to do as much work as possible in Interface Builder.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
[searchField.window makeFirstResponder:nil]
如果您只是想去掉对焦环,您可以在 NIB 中禁用它。
如果您想在用户单击窗口中的空白区域时放弃第一响应程序,则必须使用自定义
NSView
作为窗口的内容视图并覆盖mouseDown:
来调用以上方法。[searchField.window makeFirstResponder:nil]
If you just want to get rid of the focus ring, you can disable it in the NIB.
If you want to resign first responder when the user clicks empty space in the window, you have to use a custom
NSView
as the window's content view and overridemouseDown:
to call the above method.