模仿 Gtk#/gtk-sharp 中的上下文菜单
有没有某种方法可以使用 gtk 菜单项的 Menu.AttachToWidget(...) 函数来附加菜单以表示 Gtk.Textview 并让它在需要时处理显示菜单。 或者为 ButtonPressEvent 创建事件处理程序并在那里显示菜单是唯一的方法吗?
或者我错过了第三种可能性?
提前致谢。
Is there some way to use the Menu.AttachToWidget(...) function of a gtk menu item to attach the menu to say a Gtk.Textview and have it handle showing the menu when needed. Or is creating an event handler for ButtonPressEvent and showing the menu there the only way to do it?
Or is there a third possibility that I'm missing?
Thanks in Advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您错过了第三种可能性。
TextView.PopulatePopup 是当用户在 TextView 中右键单击时 TextView 触发的事件。 您可以处理此事件并将菜单项插入到现有的 TextView 上下文菜单中,其中包含用于剪切/复制/粘贴和输入法的项目。 这是向 TextView 添加附加上下文菜单项的首选方法。
文档链接:
There is a third possibility that you are missing.
TextView.PopulatePopup is an event that TextView fires when the user right clicks within the TextView. You can handle this event and insert menu items into the existing TextView context menu, which has items for cut/copy/paste and input method. This is the preferred way of adding additional context menu items to TextView.
Links to docs: