I’m trying to use a custom event in my WxWidgets C++ application, like described here.
In the constructor of my wxApp:
Connect(wxID_ANY, wxCommandEventHandler(APP::OnMyEvent));
Then the function that should catch the event:
void APP::OnMyEvent(wxCommandEvent& event)
{
exit(0); //testing
}
Finally, to test it:
wxCommandEvent MyEvent(wxEVT_COMMAND_BUTTON_CLICKED);
wxPostEvent(this, MyEvent);
I launch the thing…but it seems that the event is not posted or not caught.
Does someone understand this behaviour ?
You appear to be using the following overload of Connect:
If so, then should an event of type
wxID_ANYhappen (never?), then the connected function will be called.Perhaps you need: