Hey guys,
I found a simple use case of wxUpdateUIEvent in one of the samples that provided me with a better understanding of how it works. I thought I'd share it for anyone else who is also getting started.
In the widgets sample, the activityindicator.cpp file makes use of wxUpdateUIEvent to update the text in wxStaticText field when the "Start" or the "Stop" button is pressed. The code involving the wxUpdateUIEvent is as follows:
void OnUpdateIsRunning(wxUpdateUIEvent& event)
{
event.SetText(m_indicator && m_indicator->IsRunning()
? "Indicator is running"
: "Indicator is stopped");
}
Here are some sshots of the app as the text changes.
You can find the sample by running the project found in [wxwidgets_dir]/samples/widgets
There are still some things that I don't understand about the code that I'll try to figure out as I go through more samples. For instance,
1. How is the OnUpdateIsRunning triggered? I don't see anything explicitly linking the buttons to this event. So, how does the event know it should get triggered on button press?
2. The SetText() method is invoked on event argument even though the static text field doesn't have a handle, but still manages to update the text. I find it interesting as I would have taken a different approach (but I find this approach prettier).