From d35947a23ff89005f018e1b47e59f9689b5094d5 Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Sun, 12 Oct 2008 11:13:21 +0000 Subject: [PATCH] Set focus back to canvas when child editors are being destroyed (fixes wxGTK property selection focus bug) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56236 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/propgrid/propgrid.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 021f77cd5f..2fbaf76534 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -3458,6 +3458,25 @@ void wxPropertyGrid::SetupChildEventHandling( wxWindow* argWnd ) 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 == m_canvas ) + { + SetFocusOnCanvas(); + break; + } + parent = parent->GetParent(); + } + } + // Do not free editors immediately if processing events if ( m_wndEditor2 ) { -- 2.45.2