[Plib-users] legend update
Brought to you by:
sjbaker
|
From: stathis <st...@nt...> - 2002-01-29 09:11:45
|
Hi everyone,
I am trying to setup sliders that will update their legend with the slider value. So as I
move the slider along I can see it's value. I managed to do this with getStringValue and
then setLegend. However on a floating point slider, it send back values with too many
digits (.i.e 0.44555). I would like to display only a meanigful part of it for the user (say
0.44). I set this to happen in a generic slider cb used by many sliders as follows:
void sliderCB( puObject *sli) {
sli->setLegend(sli->getStringValue());
.....
...
}
This works fine so far. I tried to reformat it like this (amongst other ways)
void sliderCB( puObject *sli) {
float value;
char sliText[4];
slicb->getValue(&value);
sprintf(sliText, "%.2f", value);
cout << sliText << endl; // this output is *exactly* what I need
slicb->setLegend(sliText); // non-sense chars on the legend :(
...
}
No matter what I do to try and reformat the string (with sprintf), prior to sending it on the
legend, I get on my legend some strange characters. What am I possibly doing wrong?
Can somebody see my mistake above?
thanks in advance.
--st
|