1.

How Are Multiple Evt_xxx Calls Handled?

Answer»
  • I am wondering about how EVT_XXX handles multiple calls. I want to change
  • how events are handled depending upon which mode my program is in. If I call
  • EVT_XXX multiple times for the same event, each time pointing to a different
  • method, are these event HANDLERS chained or do subsequent calls replace the
  • OLD event handler?

Each instance of a class DERIVED from wxEvt

Handler has a static event table, which is used only by C++ code, and a dynamic event table (just a list really) which is what wxPython uses although a few C++ developers use it too. Every time you call a EVT_XXX function it adds an ENTRY to this list. When an event happens the first matching handler in the event table is called, and if it calls event.Skip() then the search continues so if another match is found then it is called too. The EVT_XXX functions are really just convenience wrappers around the wxEvt

Handler.Connect method. There is ALSO a .Disconnect method that you can call if needed to remove an event handler binding.

Each instance of a class derived from wxEvt

Handler has a static event table, which is used only by C++ code, and a dynamic event table (just a list really) which is what wxPython uses although a few C++ developers use it too. Every time you call a EVT_XXX function it adds an entry to this list. When an event happens the first matching handler in the event table is called, and if it calls event.Skip() then the search continues so if another match is found then it is called too. The EVT_XXX functions are really just convenience wrappers around the wxEvt

Handler.Connect method. There is also a .Disconnect method that you can call if needed to remove an event handler binding.



Discussion

No Comment Found