如何以编程方式显示 NSSearchField 菜单?
我想实现一个 NSSearchField 显示类似于 Safari 的搜索结果,但我不知道如何以编程方式显示菜单。任何指示将不胜感激。
更新:我尝试通过在 @NSButtonCell@ 对象上调用 @-performClick:@ 来以编程方式执行此操作,该对象表示搜索字段的搜索字段单元格内的搜索按钮,但是虽然我已经确认确实调用了 PerformClick,但它不会触发菜单。
I want to implement an NSSearchField showing search results similar to Safari's, but I cannot figure out how to show the menu programmatically. Any pointers would be greatly appreciated.
Update: I tried doing this programmatically by calling @-performClick:@ on the @NSButtonCell@ object that represents the search button inside the search field's search field cell, but while I have confirmed that performClick is indeed called, it does not trigger the menu.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Safari 似乎使用某种自定义或私有 API 来显示搜索结果。它可能是一个看起来像菜单的窗口。我发现的问题是,普通的弹出菜单会将键盘焦点从搜索字段中移开,这不是您想要的,即在菜单更新时能够继续在搜索字段中输入内容。我找不到简单的方法来做到这一点,但我怀疑它需要是一个看起来像菜单的子窗口。
这是一个博客,记录了添加与 Camino 类似的内容: http://summerofcamino.com/
Safari seems to use some kind of custom or private API to show search results. It's probably a window that looks like a menu. The problem I found is that a normal pop-up menu will take the keyboard focus away from the search field, which is not what you want, which is to be able to keep typing in the search field while the menu updates. I couldn't find a simple way of doing that, but I suspect it needs to be a child window that looks like a menu.
Here's a blog which documented adding something similar to Camino: http://summerofcamino.com/