wxEvent type to send text between frames without using a custom event? I need to send…
- User
wxEvent type to send text between frames without using a custom event? I need to send text between a class and a frame, but I don't want to define custom events for this.
Frame F --calls--> Class A --send information back (once or more times)--> Frame F
- Assistant
One option to send text between frames without using a custom event is to use the wxPostEvent function.
In Frame F, you can create an instance of the class A and call a function in class A that sends the text back to Frame F. After sending the text, you can use the wxPostEvent function to post an event to the Frame F with the text data.
Here is an example of how you can achieve this:
// Frame F void FrameF::OnSendText() { ClassA classA; wxString text = classA.GetText(); wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED); event.SetString(text); wxPostEvent(this, event); } // Class A class ClassA { public: wxString GetText() { return "Text from Class A"; } };In this example, when the
OnSendTextfunction is called in Frame F, it creates an instance of Class A and gets the text using theGetTextfunction. It then creates a wxCommandEvent with the text data and posts the event to Frame F using the wxPostEvent function.