From 52a368fed1b26a5c7029a26d1b885ea348020614 Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Mon, 7 Mar 2011 13:02:33 +0000 Subject: [PATCH] To prevent wxPropertyGrid from stealing frocus from other controls, only let SetFocusOnCanvas() move focus to the main grid 'canvas' if focus was already in on the grid's child controls git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67142 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/propgrid/propgrid.h | 2 ++ src/propgrid/propgrid.cpp | 34 +++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index bd3786f23f..cf6dd98c48 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -2238,6 +2238,8 @@ protected: unsigned int selFlags = wxPG_SEL_NOVALIDATE, unsigned int column = 1 ); + // This function only moves focus to the wxPropertyGrid if it already + // was on one of its child controls. void SetFocusOnCanvas(); bool DoHideProperty( wxPGProperty* p, bool hide, int flags ); diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index c494ce97fa..dba68bde37 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -3982,20 +3982,7 @@ void wxPropertyGrid::FreeEditors() // Return focus back to canvas from children (this is required at least for // GTK+, which, unlike Windows, clears focus when control is destroyed // instead of moving it to closest parent). - wxWindow* focus = wxWindow::FindFocus(); - if ( focus ) - { - wxWindow* parent = focus->GetParent(); - while ( parent ) - { - if ( parent == this ) - { - SetFocusOnCanvas(); - break; - } - parent = parent->GetParent(); - } - } + SetFocusOnCanvas(); // Do not free editors immediately if processing events if ( m_wndEditor2 ) @@ -4691,7 +4678,24 @@ void wxPropertyGrid::SetVirtualWidth( int width ) void wxPropertyGrid::SetFocusOnCanvas() { - SetFocus(); + // To prevent wxPropertyGrid from stealing focus from other controls, + // only move focus to the grid if it was already in one if its child + // controls. + wxWindow* focus = wxWindow::FindFocus(); + if ( focus ) + { + wxWindow* parent = focus->GetParent(); + while ( parent ) + { + if ( parent == this ) + { + SetFocus(); + break; + } + parent = parent->GetParent(); + } + } + m_editorFocused = 0; } -- 2.50.0