如何捕获 Gtk.TreeView 中的点击?

发布于 2024-07-19 18:39:06 字数 157 浏览 13 评论 0原文

我正在尝试捕获 TreeView 的空白区域中的双击事件以创建新节点。 不幸的是标准方法不起作用。 我尝试将 ButtonPressEvent 附加到 TreeView 和托管电视的 ScrolledWindow 。 我的函数没有收到任何回调。

我该如何解决这个问题?

I'm trying to catch a double-click event in a TreeView's empty area to create a new node. Unfortunately standard way doesn't work. I've tried attaching ButtonPressEvent to both TreeView and the ScrolledWindow in which T.V. is hosted. I don't get any callbacks to my function.

How can I solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

好久不见√ 2024-07-26 18:39:06

您需要在处理程序上使用 GLib.ConnectBeforeAttribute 来处理 TreeView.ButtonPressEvent,否则小部件将在内部处理该事件,并且不会调用您的处理程序。

例子:

[GLib.ConnectBefore]
void OnTreeViewButtonPressEvent(object sender, ButtonPressEventArgs e)
{
    if (e.Type == Gdk.EventType.TwoButtonPress)
    {
        // double click
    }
}    

You'll need to use the GLib.ConnectBeforeAttribute on your handler to handle TreeView.ButtonPressEvent, otherwise the widget will handle the event internally and your handler won't be called.

example:

[GLib.ConnectBefore]
void OnTreeViewButtonPressEvent(object sender, ButtonPressEventArgs e)
{
    if (e.Type == Gdk.EventType.TwoButtonPress)
    {
        // double click
    }
}    
乞讨 2024-07-26 18:39:06

http://old.nabble.com/CellRenderer-editable-on -双击-td24975510.html

self.treeview.connect("button-press-event",self.cell_clicked)

def cell_clicked(self, widget, event):
     if event.button == 1 and event.type == gtk.gdk.BUTTON_PRESS:
        print "Double clicked on cell"

http://old.nabble.com/CellRenderer-editable-on-double-click-td24975510.html

self.treeview.connect("button-press-event",self.cell_clicked)

def cell_clicked(self, widget, event):
     if event.button == 1 and event.type == gtk.gdk.BUTTON_PRESS:
        print "Double clicked on cell"
妥活 2024-07-26 18:39:06

我认为 Treeview 有自己的窗口。

获取窗口句柄,然后SendMessage(treeview->Getsafehwnd() , tvi_root, tvichildren)

以上发送消息仅供您理解。

I think the Treeview has a window of its own.

Get the window handle, and then SendMessage(treeview->Getsafehwnd() , tvi_root, tvichildren)

The above send message is for your understanding only .

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