diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index b6121f0083..414988125b 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -2553,8 +2553,10 @@ protected: bool Redimension( wxGridTableMessage& ); - // Send the given grid event and return -1 if it was vetoed, 1 if - // it was processed (but not vetoed) and 0 if it wasn't processed. + // Send the given grid event and return -1 if it was vetoed or, as a + // special exception, if an event for a particular cell resulted in this + // cell being deleted, 1 if it was processed (but not vetoed) and 0 if it + // wasn't processed. int DoSendEvent(wxGridEvent& gridEvt); // Generate an event of the given type and call DoSendEvent(). diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index d40c00549a..94c9723e9d 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -5294,7 +5294,7 @@ wxGrid::SendGridSizeEvent(wxEventType type, } // Process the event and return -// -1 if the event was vetoed +// -1 if the event was vetoed or if event cell was deleted // +1 if the event was processed (but not vetoed) // 0 if the event wasn't handled int wxGrid::DoSendEvent(wxGridEvent& gridEvt) @@ -5305,6 +5305,14 @@ int wxGrid::DoSendEvent(wxGridEvent& gridEvt) if ( !gridEvt.IsAllowed() ) return -1; + // We also return -1 if the event cell was deleted, as this allows to have + // checks in several functions that generate an event and then proceed + // doing something by default with the selected cell: this shouldn't be + // done if the user-defined handler deleted this cell. + if ( gridEvt.GetRow() >= GetNumberRows() || + gridEvt.GetCol() >= GetNumberCols() ) + return -1; + return claimed ? 1 : 0; }