How to catch clicks in Gtk.TreeView?

I am trying to catch a double-click event in an empty area of ​​TreeView to create a new node. Unfortunately, the standard method does not work. I tried to install ButtonPressEvent in both TreeView and ScrolledWindow, which hosts the TV. I do not receive any callbacks to my function.

How can i solve this?

+4
source share
3 answers

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

Example:

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

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" 
+2
source

I think Treeview has its own window.

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

The above send message is for your understanding only.

-4
source

All Articles