From 922bef4df62533654ce3870d7eaa14e8402d3921 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 3 Dec 2014 16:59:11 +0000 Subject: [PATCH] Restore wxPG toolbar buttons state if selecting wxPG page was unsuccessful. Toolbar button corresponding to the unsuccessfully selected page should be released and button corresponding to the old page should be pressed again. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78213 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/propgrid/manager.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/propgrid/manager.cpp b/src/propgrid/manager.cpp index 972d062528..e72dac0a0c 100644 --- a/src/propgrid/manager.cpp +++ b/src/propgrid/manager.cpp @@ -1752,13 +1752,11 @@ void wxPropertyGridManager::OnToolbarClick( wxCommandEvent &event ) // Page Switching. int index = -1; - size_t i; - wxPropertyGridPage* pdc; // Find page with given id. - for ( i=0; im_toolId == id ) { index = i; @@ -1768,14 +1766,25 @@ void wxPropertyGridManager::OnToolbarClick( wxCommandEvent &event ) wxASSERT( index >= 0 ); - if ( DoSelectPage( index ) ) + if ( DoSelectPage(index) ) { // Event dispatching must be last. - m_pPropGrid->SendEvent( wxEVT_PG_PAGE_CHANGED, NULL ); + m_pPropGrid->SendEvent( wxEVT_PG_PAGE_CHANGED, NULL ); } else { - // TODO: Depress the old button on toolbar. + // Restore button state on toolbar. + wxToolBar* tb = wxDynamicCast(event.GetEventObject(), wxToolBar); + wxASSERT( tb ); + + // Release the current button. + tb->ToggleTool(id, false); + // Depress the old button. + if ( m_selPage >= 0 ) + { + wxPropertyGridPage* prevPage = m_arrPages[m_selPage]; + tb->ToggleTool(prevPage->m_toolId, true); + } } } }