I am currently trying to create my own event so that I can propagate coordinate positions from the canvas to the parent class so that I can display the position of the mouse pointer on the frame of the application.
I am using this site as a reference: https://wiki.wxwidgets.org/Custom_Events
At the site, I am using the following code:
Code: Select all
wxDEFINE_EVENT(MY_NEW_TYPE, wxCommandEvent);
wxCommandEvent event(MY_NEW_TYPE); // No specific id
// Add any data; sometimes the only information needed at the destination is the arrival of the event itself
event.SetString("This is the data");
// Then post the event
wxPostEvent(this, event); // to ourselves
wxPostEvent(pBar, event); // or to a different instance or class
The code below is what I have defined in my main frame class (The parent):
Code: Select all
wxBEGIN_EVENT_TABLE(MyFoo, wxFoo))
EVT_COMMAND(wxID_ANY, MY_NEW_TYPE, MyFoo::OnMyEvent)
...
wxEND_EVENT_TABLE()
My small issue that I am running into is that my main frame class will not be able to know what is MY_NEW_TYPE since the canvas class and the main frame class use different .cpp file. With wxDefine_EVENT only being used in one class, what is hte best solution to define the Event in my main class so that the main frame class will be able to understand the MY_NEW_TYPE?