diff --git a/docs/changes.txt b/docs/changes.txt index b77fc6f0cb..f98da8838d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -128,6 +128,7 @@ All (GUI): - Allow period in link anchors in wxHTML. - Fixed memory corruption in wxHTML when parsing "&;" in the markup. - Fixed event type in EVT_GRID_CMD_COL_MOVE and EVT_GRID_COL_MOVE. +- wxGrid doesn't steal focus when hiding editor any more (Tom Eckert). All (Unix): diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index d022d8b421..86738f9e3a 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -8590,11 +8590,19 @@ void wxGrid::HideCellEditControl() wxGridCellAttr *attr = GetCellAttr(row, col); wxGridCellEditor *editor = attr->GetEditor(this, row, col); + const bool + editorHadFocus = wxWindow::FindFocus() == editor->GetControl(); 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) );