]> git.saurik.com Git - wxWidgets.git/commitdiff
don't steal focus back to wxGrid when it hides an editor in the result of losing...
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 15 Sep 2008 00:28:15 +0000 (00:28 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 15 Sep 2008 00:28:15 +0000 (00:28 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55632 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/grid.cpp

index f3e87515e50743221c45b5ce1de81b7b0805dce2..45df39c603aecceb066824f7a00afe105ed75331 100644 (file)
@@ -8508,11 +8508,18 @@ void wxGrid::HideCellEditControl()
 
         wxGridCellAttr *attr = GetCellAttr(row, col);
         wxGridCellEditor *editor = attr->GetEditor(this, row, col);
 
         wxGridCellAttr *attr = GetCellAttr(row, col);
         wxGridCellEditor *editor = attr->GetEditor(this, row, col);
+        const bool editorHadFocus = editor->GetControl()->HasFocus();
         editor->Show( false );
         editor->DecRef();
         attr->DecRef();
 
         editor->Show( false );
         editor->DecRef();
         attr->DecRef();
 
-        m_gridWin->SetFocus();
+        // return the focus to the grid itself if the editor had it
+        //
+        // note that we must not do this unconditionally to avoid stealing
+        // focus from the window which just received it if we are hiding the
+        // editor precisely because we lost focus
+        if ( editorHadFocus )
+            m_gridWin->SetFocus();
 
         // refresh whole row to the right
         wxRect rect( CellToRect(row, col) );
 
         // refresh whole row to the right
         wxRect rect( CellToRect(row, col) );