Avoid bogus context menu events in wxGTK wxDataViewCtrl
Right clicking on the column header shouldn't generate context menu events, but it did because our gtk_dataview_button_press_callback() got these events for both the "bin" window, containing the items, and the "header" window. Fix this by filtering out the events not sent to the right window. It would be even better to not get these events in the first place, i.e. somehow not connect to them in the first place, but it's not clear how to do this, so settle for this solution for now. For testing this fix, just right click any column in the dataview sample: previously this generated both messages about the column header right click and the context menu in wxGTK, while now it only generates the former, as in the generic version.
This commit is contained in:
@@ -4664,6 +4664,13 @@ gtk_dataview_button_press_callback( GtkWidget *WXUNUSED(widget),
|
||||
{
|
||||
GtkTreeView* const treeview = GTK_TREE_VIEW(dv->GtkGetTreeView());
|
||||
|
||||
// Surprisingly, we can get the events not only from the "bin" window,
|
||||
// containing the items, but also from the window containing the column
|
||||
// headers, and we're not interested in them here, we already generate
|
||||
// wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK for them, so just ignore.
|
||||
if (gdk_event->window != gtk_tree_view_get_bin_window(treeview))
|
||||
return FALSE;
|
||||
|
||||
wxGtkTreePath path;
|
||||
GtkTreeViewColumn *column = NULL;
|
||||
gint cell_x = 0;
|
||||
|
Reference in New Issue
Block a user