diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 1d47ea384f..38a51453e8 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -2908,8 +2908,11 @@ private: ); } - // Accept the changes in the edit control, if it's currently shown, and - // dismiss it. + // Accept the changes in the edit control, i.e. save them to the table and + // dismiss the editor. + void DoAcceptCellEditControl(); + + // As above, but do nothing if the control is not currently shown. void AcceptCellEditControlIfShown(); // Unlike the public SaveEditControlValue(), this method doesn't check if diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 206ffcab4a..675f6d2b75 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -7170,15 +7170,7 @@ void wxGrid::EnableCellEditControl( bool enable ) { SendEvent(wxEVT_GRID_EDITOR_HIDDEN); - HideCellEditControl(); - - // do it after HideCellEditControl() but before invoking - // user-defined handlers invoked by DoSaveEditControlValue() to - // ensure that we don't enter infinite loop if any of them try to - // disable the edit control again. - m_cellEditCtrlEnabled = false; - - DoSaveEditControlValue(); + DoAcceptCellEditControl(); } } } @@ -7415,11 +7407,24 @@ void wxGrid::AcceptCellEditControlIfShown() { if ( IsCellEditControlShown() ) { - HideCellEditControl(); - DoSaveEditControlValue(); + DoAcceptCellEditControl(); } } +void wxGrid::DoAcceptCellEditControl() +{ + HideCellEditControl(); + + // do it after HideCellEditControl() but before invoking + // user-defined handlers invoked by DoSaveEditControlValue() to + // ensure that we don't enter infinite loop if any of them try to + // disable the edit control again by calling DisableCellEditControl() + // from which we can be called + m_cellEditCtrlEnabled = false; + + DoSaveEditControlValue(); +} + void wxGrid::SaveEditControlValue() { if ( IsCellEditControlEnabled() )