如何在按下热键时在插入点上显示弹出窗口
我想知道,苹果的字典应用程序如何在任何应用程序中的单词上按 cmd+ctrl+d 显示弹出窗口。请让我知道我将如何为我的可可应用程序实现同样的目标。
I want to know, how apple's dictionary app is showing popup on pressing cmd+ctrl+d on word in any application. Please let me know how I'll achieve the same for my cocoa app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想您可以使用
NSRect insertRect=[[selflayoutManager]boundingRectForGlyphRange:[self selectedRange] inTextContainer:[self textContainer]]
获取选择的位置,然后使用insertionRect.origin
创建该弹出窗口code> 作为其框架的起源。I guess you get the selection's position with
NSRect insertionRect=[[self layoutManager] boundingRectForGlyphRange:[self selectedRange] inTextContainer:[self textContainer]]
and then create that popup usinginsertionRect.origin
as the origin of its frame.