diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 38a51453e8..ec0ce7b6eb 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -1504,7 +1504,7 @@ public: void EnableCellEditControl( bool enable = true ); void DisableCellEditControl() { EnableCellEditControl(false); } bool CanEnableCellControl() const; - bool IsCellEditControlEnabled() const; + bool IsCellEditControlEnabled() const { return m_cellEditCtrlEnabled; } bool IsCellEditControlShown() const; bool IsCurrentCellReadOnly() const; diff --git a/interface/wx/grid.h b/interface/wx/grid.h index aa9a6b4a45..245b570779 100644 --- a/interface/wx/grid.h +++ b/interface/wx/grid.h @@ -3440,6 +3440,9 @@ public: currently show, otherwise the @c wxEVT_GRID_EDITOR_HIDDEN event is generated but, unlike the "shown" event, it can't be vetoed and the in-place editor is dismissed unconditionally. + + Note that it is an error to call this function if the current cell is + read-only, use CanEnableCellControl() to check for this precondition. */ void EnableCellEditControl(bool enable = true); diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 99f2b4e2cc..258b4c33b8 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -7149,12 +7149,12 @@ void wxGrid::EnableCellEditControl( bool enable ) { if ( enable ) { + // this should be checked by the caller! + wxCHECK_RET( CanEnableCellControl(), wxT("can't enable editing for this cell!") ); + if ( SendEvent(wxEVT_GRID_EDITOR_SHOWN) == -1 ) return; - // this should be checked by the caller! - wxASSERT_MSG( CanEnableCellControl(), wxT("can't enable editing for this cell!") ); - // do it before ShowCellEditControl() m_cellEditCtrlEnabled = enable; @@ -7181,13 +7181,6 @@ bool wxGrid::CanEnableCellControl() const !IsCurrentCellReadOnly(); } -bool wxGrid::IsCellEditControlEnabled() const -{ - // the cell edit control might be disable for all cells or just for the - // current one if it's read only - return m_cellEditCtrlEnabled ? !IsCurrentCellReadOnly() : false; -} - bool wxGrid::IsCellEditControlShown() const { bool isShown = false;