Re: How do I catch right-click on a TreeView header?

John M Collins wrote:
I gave that a try, gtk_tree_view_column_get_widget() returns NULL unless
you've set a widget.

I've now got it displaying label widgets but alas the connection of
button-press-event doesn't seem to do anything. I still get the sorting
action on the left button of the mouse but nothing happens when I
right-click and it doesn't enter my event-handling routine.

Ideas would be valued. Thanks.

I did something like this.

gtk_tree_view_column_set_widget(column, label);
GtkWidget *col_button = gtk_widget_get_ancestor(label, GTK_TYPE_BUTTON);
g_signal_connect(G_OBJECT(GTK_WIDGET(col_button)), "button-press-event",
                          G_CALLBACK(header_right_click_cb), cwin);

In the handler, you can check for button 3 and popup a menu.
But this might break if the internal implementation of GtkTreeView header changes.
It works for now.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]