From bae200a453fd58ff6f737a003148e380dd210ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sat, 23 Nov 2013 10:56:09 +0000 Subject: [PATCH] Fix selection behavior on right-click in wxGTK wxDataViewCtrl. Select the item under the cursor even when right-clicking it, because it's expected behavior (Nautilus does it too). Fixes #13531. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75273 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/dataview.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 38a0516869..7a181fd4c5 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -4441,6 +4441,16 @@ gtk_dataview_button_press_callback( GtkWidget *WXUNUSED(widget), &cell_y ); + // If the right click is on an item that isn't selected, select it, as is + // commonly done. Do not do it if the item under mouse is already selected, + // because it could be a part of multi-item selection. + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dv->GtkGetTreeView())); + if ( !gtk_tree_selection_path_is_selected(selection, path) ) + { + gtk_tree_selection_unselect_all(selection); + gtk_tree_selection_select_path(selection, path); + } + wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_CONTEXT_MENU, dv->GetId() ); if (path) event.SetItem(dv->GTKPathToItem(path));