Page 1 of 1

event.skip() in .h preventing derived classes from running

Posted: Fri Mar 04, 2022 7:36 pm
by antoniochang

I couldn't get my event handlers to work because the code is only able to enter the parent class' virtual handler which contains "event.Skip()". I added the following line in the derived class' function:
wxMessageBox("Hello World");
where nothing happens. However, replacing the event.Skip() with the above line in wxcrafter.h file (which is autogenerated by wxCrafter) works.

What needs to be done to get the event handler working? Thanks!


Re: event.skip() in .h preventing derived classes from running

Posted: Fri Mar 04, 2022 11:52 pm
by DavidGH

Hi,

(This is a composite reply to both your threads, as I think the issue is the same for each.)

IIUC you are trying to use the wxCrafter-generated classes direct. Instead you should use them as base-classes to your real code. In fact I usually name the generated files foobase.cpp/h, containing class FooBase; then my Foo.cpp/h contains class Foo and #includes foobase.h.

In your derived class you can override the event handler function. You should then find that the events are correctly caught.

Regards,

David


Re: event.skip() in .h preventing derived classes from running

Posted: Sat Mar 05, 2022 6:37 pm
by antoniochang

That solved it, thanks so much!