diff --git a/clientgui/BOINCBaseView.cpp b/clientgui/BOINCBaseView.cpp index e418b04b6a..fd3ae61d67 100644 --- a/clientgui/BOINCBaseView.cpp +++ b/clientgui/BOINCBaseView.cpp @@ -331,6 +331,8 @@ bool CBOINCBaseView::OnRestoreState(wxConfigBase* pConfig) { } +// We don't currently use this because selecting an item +// triggers an EVT_LIST_CACHE_HINT; see OnCacheHint() below. void CBOINCBaseView::OnListSelected(wxListEvent& event) { wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseView::OnListSelected - Function Begin")); @@ -344,6 +346,8 @@ void CBOINCBaseView::OnListSelected(wxListEvent& event) { } +// We don't currently use this because selecting an item +// triggers an EVT_LIST_CACHE_HINT; see OnCacheHint() below. void CBOINCBaseView::OnListDeselected(wxListEvent& event) { wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseView::OnListDeselected - Function Begin")); @@ -361,20 +365,30 @@ void CBOINCBaseView::OnListDeselected(wxListEvent& event) { // * It does not send deselection events. // * It (apparently intentionally) does not send selection // events if you add to selection using Shift_Click. +// +// We currently handle all selections and deselections here. void CBOINCBaseView::OnCacheHint(wxListEvent& event) { static int oldSelectionCount = 0; + static long previousSelection = -1; + + bool selectionChanged = false; int newSelectionCount = m_pListPane->GetSelectedItemCount(); - - if (newSelectionCount < oldSelectionCount) { - wxListEvent leDeselectedEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED, m_windowId); - leDeselectedEvent.SetEventObject(this); - OnListDeselected(leDeselectedEvent); - } else if (newSelectionCount > oldSelectionCount) { - wxListEvent leSelectedEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED, m_windowId); - leSelectedEvent.SetEventObject(this); - OnListSelected(leSelectedEvent); + long currentSelection = m_pListPane->GetFirstSelected(); + + if (newSelectionCount != oldSelectionCount) { + selectionChanged = true; + } else if (currentSelection != previousSelection) { + selectionChanged = true; } + if (selectionChanged) { + if (!m_bIgnoreUIEvents) { + m_bForceUpdateSelection = true; + UpdateSelection(); + } + } + oldSelectionCount = newSelectionCount; + previousSelection = currentSelection; event.Skip(); } diff --git a/clientgui/ViewProjects.cpp b/clientgui/ViewProjects.cpp index f39d1789e7..9ab2408831 100644 --- a/clientgui/ViewProjects.cpp +++ b/clientgui/ViewProjects.cpp @@ -82,10 +82,12 @@ BEGIN_EVENT_TABLE (CViewProjects, CBOINCBaseView) EVT_BUTTON(ID_TASK_PROJECT_DETACH, CViewProjects::OnProjectDetach) EVT_BUTTON(ID_TASK_PROJECT_SHOW_PROPERTIES, CViewProjects::OnShowItemProperties) EVT_CUSTOM_RANGE(wxEVT_COMMAND_BUTTON_CLICKED, ID_TASK_PROJECT_WEB_PROJDEF_MIN, ID_TASK_PROJECT_WEB_PROJDEF_MAX, CViewProjects::OnProjectWebsiteClicked) - EVT_LIST_ITEM_SELECTED(ID_LIST_PROJECTSVIEW, CViewProjects::OnListSelected) - EVT_LIST_ITEM_DESELECTED(ID_LIST_PROJECTSVIEW, CViewProjects::OnListDeselected) - EVT_LIST_COL_CLICK(ID_LIST_PROJECTSVIEW, CViewProjects::OnColClick) +// We currently handle EVT_LIST_CACHE_HINT instead of EVT_LIST_ITEM_SELECTED +// or EVT_LIST_ITEM_DESELECTED. See CBOINCBaseView::OnCacheHint() for info. +// EVT_LIST_ITEM_SELECTED(ID_LIST_PROJECTSVIEW, CViewProjects::OnListSelected) +// EVT_LIST_ITEM_DESELECTED(ID_LIST_PROJECTSVIEW, CViewProjects::OnListDeselected) EVT_LIST_CACHE_HINT(ID_LIST_PROJECTSVIEW, CViewProjects::OnCacheHint) + EVT_LIST_COL_CLICK(ID_LIST_PROJECTSVIEW, CViewProjects::OnColClick) EVT_LIST_COL_END_DRAG(ID_LIST_PROJECTSVIEW, CViewProjects::OnColResize) END_EVENT_TABLE () diff --git a/clientgui/ViewStatistics.cpp b/clientgui/ViewStatistics.cpp index 5990771724..7a45a6fde1 100644 --- a/clientgui/ViewStatistics.cpp +++ b/clientgui/ViewStatistics.cpp @@ -1940,8 +1940,6 @@ BEGIN_EVENT_TABLE (CViewStatistics, CBOINCBaseView) EVT_BUTTON(ID_TASK_STATISTICS_NEXTPROJECT, CViewStatistics::OnStatisticsNextProject) EVT_BUTTON(ID_TASK_STATISTICS_PREVPROJECT, CViewStatistics::OnStatisticsPrevProject) EVT_BUTTON(ID_TASK_STATISTICS_HIDEPROJLIST, CViewStatistics::OnShowHideProjectList) - EVT_LIST_ITEM_SELECTED(ID_LIST_STATISTICSVIEW, CViewStatistics::OnListSelected) - EVT_LIST_ITEM_DESELECTED(ID_LIST_STATISTICSVIEW, CViewStatistics::OnListDeselected) END_EVENT_TABLE () CViewStatistics::CViewStatistics() diff --git a/clientgui/ViewTransfers.cpp b/clientgui/ViewTransfers.cpp index 16c4ac293c..aa7009c9c9 100644 --- a/clientgui/ViewTransfers.cpp +++ b/clientgui/ViewTransfers.cpp @@ -68,10 +68,12 @@ IMPLEMENT_DYNAMIC_CLASS(CViewTransfers, CBOINCBaseView) BEGIN_EVENT_TABLE (CViewTransfers, CBOINCBaseView) EVT_BUTTON(ID_TASK_TRANSFERS_RETRYNOW, CViewTransfers::OnTransfersRetryNow) EVT_BUTTON(ID_TASK_TRANSFERS_ABORT, CViewTransfers::OnTransfersAbort) - EVT_LIST_ITEM_SELECTED(ID_LIST_TRANSFERSVIEW, CViewTransfers::OnListSelected) - EVT_LIST_ITEM_DESELECTED(ID_LIST_TRANSFERSVIEW, CViewTransfers::OnListDeselected) - EVT_LIST_COL_CLICK(ID_LIST_TRANSFERSVIEW, CViewTransfers::OnColClick) +// We currently handle EVT_LIST_CACHE_HINT instead of EVT_LIST_ITEM_SELECTED +// or EVT_LIST_ITEM_DESELECTED. See CBOINCBaseView::OnCacheHint() for info. +// EVT_LIST_ITEM_SELECTED(ID_LIST_TRANSFERSVIEW, CViewTransfers::OnListSelected) +// EVT_LIST_ITEM_DESELECTED(ID_LIST_TRANSFERSVIEW, CViewTransfers::OnListDeselected) EVT_LIST_CACHE_HINT(ID_LIST_TRANSFERSVIEW, CViewTransfers::OnCacheHint) + EVT_LIST_COL_CLICK(ID_LIST_TRANSFERSVIEW, CViewTransfers::OnColClick) EVT_LIST_COL_END_DRAG(ID_LIST_TRANSFERSVIEW, CViewTransfers::OnColResize) END_EVENT_TABLE () diff --git a/clientgui/ViewWork.cpp b/clientgui/ViewWork.cpp index 0bd32c4d6d..4eb4388a16 100644 --- a/clientgui/ViewWork.cpp +++ b/clientgui/ViewWork.cpp @@ -89,10 +89,12 @@ BEGIN_EVENT_TABLE (CViewWork, CBOINCBaseView) EVT_BUTTON(ID_TASK_SHOW_PROPERTIES, CViewWork::OnShowItemProperties) EVT_BUTTON(ID_TASK_ACTIVE_ONLY, CViewWork::OnActiveTasksOnly) EVT_CUSTOM_RANGE(wxEVT_COMMAND_BUTTON_CLICKED, ID_TASK_PROJECT_WEB_PROJDEF_MIN, ID_TASK_PROJECT_WEB_PROJDEF_MAX, CViewWork::OnProjectWebsiteClicked) - EVT_LIST_ITEM_SELECTED(ID_LIST_WORKVIEW, CViewWork::OnListSelected) - EVT_LIST_ITEM_DESELECTED(ID_LIST_WORKVIEW, CViewWork::OnListDeselected) - EVT_LIST_COL_CLICK(ID_LIST_WORKVIEW, CViewWork::OnColClick) +// We currently handle EVT_LIST_CACHE_HINT instead of EVT_LIST_ITEM_SELECTED +// or EVT_LIST_ITEM_DESELECTED. See CBOINCBaseView::OnCacheHint() for info. +// EVT_LIST_ITEM_SELECTED(ID_LIST_WORKVIEW, CViewWork::OnListSelected) +// EVT_LIST_ITEM_DESELECTED(ID_LIST_WORKVIEW, CViewWork::OnListDeselected) EVT_LIST_CACHE_HINT(ID_LIST_WORKVIEW, CViewWork::OnCacheHint) + EVT_LIST_COL_CLICK(ID_LIST_WORKVIEW, CViewWork::OnColClick) EVT_LIST_COL_END_DRAG(ID_LIST_WORKVIEW, CViewWork::OnColResize) END_EVENT_TABLE ()