Hi,
When a user changes the content of a wxGrid cell, I would like to have
a validation function run on the changed value to see if the change is
acceptible. If not, a message box shall pop up and the focus should
remain in the cell being edited.
In the wxGrid demo GridSimple.py I found the following code snippet,
which seems to be the solution:
def OnEditorHidden(self, evt):
if evt.GetRow() == 6 and evt.GetCol() == 3 and \
wx.MessageBox("Are you sure you wish to finish editing this cell?",
"Checking", wx.YES_NO) == wx.NO:
evt.Veto()
return
self.log.write("OnEditorHidden: (%d,%d) %s\n" %
(evt.GetRow(), evt.GetCol(), evt.GetPosition()))
evt.Skip()
It seems if the user vetos the edit, the previous change wouldn't be
made final by the grid. However, when I run the sample (under Linux
with wxPython-2.6.1-unicode), no matter what I choose, the content of
the cell is changed. The evt.Veto() doesn't seem to have any effect.
Desipte the call to evt.Veto(), the EVT_GRID_CELL_CHANGE event is
always triggered and the current cell moved to the cell below.
Why is evt.Veto() here not functioning as I expected?
Best Regards