From d51d330f78f11160509a764060ecc17a731e97cf Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 17 Nov 2024 14:38:20 +0100 Subject: Fix multi-selection of content. In order to add ellipsizing of text we're using this "mode" of wxListCtrl where `OnGetItemAttr` is called to get information about an item. This was intended to support very long lists, so that the whole list does not have to be given to wxListCtrl. However, in this mode, multiple selections (e.g. shift-click) are just not reported. There's a 13-year-old wxWidgets bug to fix this: https://github.com/wxWidgets/wxWidgets/issues/4541 and there is mentioned the workaround applied here - listen to the focused event. We have to delay it because on macOS (at least) the selection state is not updated until after the focused event. --- src/wx/content_panel.cc | 8 ++++++++ src/wx/content_panel.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 9e73900fc..31dd56151 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -300,6 +300,7 @@ ContentPanel::ContentPanel(wxNotebook* n, shared_ptr film, FilmViewer& vie _content->Bind (wxEVT_LIST_ITEM_SELECTED, boost::bind (&ContentPanel::item_selected, this)); _content->Bind (wxEVT_LIST_ITEM_DESELECTED, boost::bind (&ContentPanel::item_deselected, this)); + _content->Bind (wxEVT_LIST_ITEM_FOCUSED, boost::bind (&ContentPanel::item_focused, this)); _content->Bind (wxEVT_LIST_ITEM_RIGHT_CLICK, boost::bind (&ContentPanel::right_click, this, _1)); _content->Bind (wxEVT_DROP_FILES, boost::bind (&ContentPanel::files_dropped, this, _1)); _add_file->Bind (wxEVT_BUTTON, boost::bind (&ContentPanel::add_file_clicked, this)); @@ -449,6 +450,13 @@ ContentPanel::item_selected () } +void +ContentPanel::item_focused() +{ + signal_manager->when_idle(boost::bind(&ContentPanel::check_selection, this)); +} + + void ContentPanel::check_selection () { diff --git a/src/wx/content_panel.h b/src/wx/content_panel.h index ca0d49719..45478a699 100644 --- a/src/wx/content_panel.h +++ b/src/wx/content_panel.h @@ -102,6 +102,7 @@ private: void item_selected (); void item_deselected (); void item_deselected_idle (); + void item_focused (); void check_selection (); void add_folder_clicked (); void add_dcp_clicked (); -- cgit v1.2.3