dartsim / grip-samples

Sample Tabs for the GRIP DART projects
1 stars 9 forks source link

Change examples to use specialized wx event macros and individual event handling functions #5

Open saulrh opened 11 years ago

saulrh commented 11 years ago

Currently, most of the examples use a single EVT_COMMAND set to handle wxID_ANY by dispatching it to a general OnButton with a switch that dispatches to the correct button. This is cumbersome and big switch statements are annoying. Instead, we should be using EVT_BUTTON to create the event table and individual handlers directly connected to the event IDs, like so:

enum TabEventIDs { id_button_action1 = wxID_HIGHEST+1 }; BEGIN_EVENT_TABLE(Tab, wxPanel) EVT_BUTTON(id_button_action1, Tab::OnAction1) END_EVENT_TABLE() void Tab::OnAction1(wxCommandEvent& evt) { }

tobiaskunz commented 11 years ago

I totally agree. The way it is done currently is a mess. I am currently doing that for the planningTab as part of an overall clean-up of that example.