From c175155bad8b3677842cdf3c8a02e4fd7d352a1e Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Thu, 11 Mar 2021 20:18:31 +0100 Subject: [PATCH] Fix higlighting properties in wxPropertyGrid without focus When wxPropertyGrid lost the focus all selected properties (not only the first one) should be redrawn to present their non-focused state. Closes #19094. --- src/propgrid/propgrid.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 61be08bb01..fc515e5a0f 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -2129,8 +2129,6 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc, wxBrush capbgbrush(m_colCapBack,wxBRUSHSTYLE_SOLID); wxPen linepen(m_colLine,1,wxPENSTYLE_SOLID); - wxColour selBackCol = isPgEnabled ? m_colSelBack : m_colMargin; - // pen that has same colour as text wxPen outlinepen(m_colPropFore,1,wxPENSTYLE_SOLID); @@ -2294,20 +2292,20 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc, renderFlags |= wxPGCellRenderer::DontUseCellFgCol | wxPGCellRenderer::DontUseCellBgCol; - if ( reallyFocused && p == firstSelected ) + if ( reallyFocused ) { - rowFgCol = m_colSelFore; - rowBgCol = selBackCol; + rowFgCol = (p == firstSelected) ? m_colSelFore : m_colPropFore; + rowBgCol = m_colSelBack; } else if ( isPgEnabled ) { rowFgCol = m_colPropFore; - rowBgCol = p == firstSelected ? m_colMargin : selBackCol; + rowBgCol = m_colMargin; } else { rowFgCol = m_colDisPropFore; - rowBgCol = selBackCol; + rowBgCol = m_colMargin; } } } @@ -6040,9 +6038,14 @@ void wxPropertyGrid::HandleFocusChange( wxWindow* newFocused ) } // Redraw selected - wxPGProperty* selected = GetSelection(); - if ( selected && (m_iFlags & wxPG_FL_INITIALIZED) ) - DrawItem( selected ); + if ( m_iFlags & wxPG_FL_INITIALIZED ) + { + const wxArrayPGProperty& sel = GetSelectedProperties(); + for ( size_t i = 0; i < sel.size(); i++ ) + { + DrawItem(sel[i]); + } + } } }