I have searched far and wide and thought different options for quite a while, and am now absolutely stumped. I created a simple class that makes 16 buttons and assigns IDs to them in the constructor. I would like each of the buttons to have an event triggered when clicked.
Class in the header:
class step16
{
///signals and buttons
private:
wxButton* sequencer [16];
long* ids = new long[16];
public:
step16(wxFrame* frame);
~step16();
};
Declaration of the functions in the source file:
///constructor for 16 step sample sequencer class
step16::step16(wxFrame* frame)
{
///clear all signals on initialization and create buttons
for(int i = 0; i < 16; i++){
ids [i] = wxNewId();
sequencer[i] = new wxButton(frame,ids[i],wxString::Format(_("")),
wxPoint(i*30 , 0,wxSize(30,20) );
}
}
///destructor for the 16 step sequencer class
step16::~step16(){delete[]signals;}
The only way I know how to add click events to buttons in wxWidgets is using the Connect() method in the initialization part of the Main wxFrame, but connecting them in that part of the program would not bring the desired results. Mainly because I need a new set of 16 buttons with unique IDs and events in every instance of the step16 class. How would I go about adding unique click events to each of these buttons?