模仿 Gtk#/gtk-sharp 中的上下文菜单

发布于 2024-07-25 04:30:56 字数 179 浏览 1 评论 0原文

有没有某种方法可以使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

池木 2024-08-01 04:30:56

您错过了第三种可能性。

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:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文