Hi all,
I'm making a scrollable list of buttons that all share the same call
back function. The idea is that the a list of names is read in from a
file. Some processing is done with the names and then the buttons are
created and positioned with a scrollbar within a puGroup. The buttons
are labelled in a separate method by iterating through a vector which
contains all the names. When the button is clicked the common
callback reads the legend from button and calls another method which
uses this as one of its arguments. The problem is that when a button is
clicked the text that is created by the method called from the call back
is garbled and the labels on the buttons appears on the wrong buttons at
random.
I've tried using strings instead of character pointers, declaring the
button in the create buttons method, the list goes on.
I noticed that if I don't assign a callback to any of the buttons then I
can click them and scroll the list and the button labels are fine. I
re-enabled the button callback and commented out the code inside so it
was an empty method. This time the text still gets jumbled on the
button list.
This is a sample of the code for the create button method:
static puGroup *recordBtnGRP;
static puOneShot *recordButton;
static puScrollBar *recordBtnSlider;
createButtons()
{
For( the number of names)
{
//This deals with adding the buttons
to the group thats been made for them.
recordButton = new puOneShot( 0 , 0,
recordBtnWidth, 20) ;
recordButton->setPosition(RGmainX,
22*(currentCount));
recordButton->setCallback(
recordBtn_CB ) ;
recordBtnGRP->add(recordButton);
}
//if the scrollbar is enabled
if(activeScrollBar)
{
recordBtnSlider = new puScrollBar(
recordBtnWidth, -5, window_height - (40 + RGmainY), 0, true, 10);
recordBtnSlider->setMinValue(0.0);
recordBtnSlider->setMaxValue(currentCount -
recordBtnGRP->getNumChildren());
recordBtnSlider->setStepSize(1.0);
recordBtnSlider->setValue(currentRecordBTN);
recordBtnSlider->setCallback(recordBtnSlider_CB);
recordBtnGRP->add(recordBtnSlider);
}
}
-Simon
|