4

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?

viraptor
  • 33,322
  • 10
  • 107
  • 191

3 Answers3

8

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
    }
}    
anthony
  • 40,424
  • 5
  • 55
  • 128
2

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"
viraptor
  • 33,322
  • 10
  • 107
  • 191
city
  • 21
  • 2
-4

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 .

Sujay Ghosh
  • 2,828
  • 8
  • 30
  • 47
  • Not sure which toolkit are you talking about, but it doesn't seem to be Gtk ;) – viraptor May 11 '09 at 17:58
  • No it's not GTK , its Windows programming. I believe that GTK shall have a similar thing. Toolkits are wrapper around the basics,. I believe. – Sujay Ghosh May 12 '09 at 07:44