[Gtk-sharp-list] TreeView context popup menu

misleb@onshore.com misleb@onshore.com
Wed, 25 Feb 2004 22:32:07 -0600

There was a thread about context menus in a treeview about a year ago on this
list, but it never really seemed to get resolved. I'm still not sure how to do
it. You'd think it would be a pretty standard feature. I mean, if you want to
add a leaf to a treeview from the GUI, the most natural thing to do would be
right click and scroll down to "Create" or if you want to delete, right click
and scroll down to "Delete," right?

Anyway, from what I understand, the problem is that the "ButtonPressEvent" isn't
valid in a TreeView. For some reason, programmers are not supposed ot have
access to button presses in a treeview. It is in some FAQ and it isn't
considered a bug. Well, what I did was override OnButtonPressEvent, call the
base OnButtonPressEvent, then trigger my own  event, passing the button args
along. I guess this crashed gtk-sharp 0.15, but it works on 0.16. 

My problem now is that I can't tell the difference between a button press on a
row or a button press on empty space. My code knows its "context" by the
currently selected row in teh tree. Which works most of the time... unless you
are clicking on blank space, in which case, you'd want to pull up a different
menu. Possibly a "global" menu for the treeview. 

Is there any reliable way for me to know if the pointer is currently over a row
during an event?