Event management in GridSimple demo

hello, in GridSimple.py demo the EVT_GRID_EDITOR_HIDDEN event is managed to show a message dialog. The strange thing is that the message dialog is shown two times, one after the other. How can I make it appear just once? Don’t know if it is a bug but can’t figure out how to change event propagation to have just one message
I’m on win 10, same behaviour with wxpy 4.0.7.post2 and 4.2.1a1

thank you in advance

Marco

On linux, if I press the Esc key to abandon editing I do get 2 message dialogs.

However, if I just move the mouse pointer outside of the frame to a different window, I only get one message dialog when the frame loses the focus.

Could it be that pressing the Esc key triggers one EVT_GRID_EDITOR_HIDDEN event which causes the first message dialog to appear and thus the frame loses the focus, which triggers then the second EVT_GRID_EDITOR_HIDDEN event?

If I unbind the the event handler before displaying the message dialog and then restore it afterwards, I only get one message dialog when pressing the Esc key (on linux at least).

    def OnEditorHidden(self, evt):
        if evt.GetRow() == 6 and evt.GetCol() == 3:
            self.Unbind(gridlib.EVT_GRID_EDITOR_HIDDEN)
            if wx.MessageBox("Are you sure you wish to  finish editing this cell?",
                        "Checking", wx.YES_NO) == wx.NO:
                evt.Veto()
                self.Bind(gridlib.EVT_GRID_EDITOR_HIDDEN, self.OnEditorHidden)
                return
            self.Bind(gridlib.EVT_GRID_EDITOR_HIDDEN, self.OnEditorHidden)

        self.log.write("OnEditorHidden: (%d,%d) %s\n" %
                       (evt.GetRow(), evt.GetCol(), evt.GetPosition()))
        evt.Skip()

1 Like

hello Richard, it works fine also on win10

Thank you very much