[SOLVED] ofxGui : update gui when value change?

Hello,

I am using the core addon ofxGui to build a small app along with ofParameter.

I can change values in my code when moving a slider.

But what if i want to update the slider when a value changes ?

For example : i have a kinect and i want to see a slider to move to the position detected by the kinect.

thanks a lot

just change the parameter and the gui will update accordingly. it’s demoed in the guiFromParametersExample but in general it’s as easy as assigning a value to the parameter as if it was a normal variable.

1 Like

oh great !
too simple i didn’t even think about it :wink:

thanks a lot

This doesn’t work for me.

Code:

parameters.add(waveOrigin.set(“wave origin”, ofVec2f(-0.5f, 0.0f), ofVec2f(-0.5f, -0.5f), ofVec2f(0.5f, 0.5f)));
waveOrigin.addListener(this, &shSharedResources::waveOriginListener);
void shSharedResources::waveOriginListener(ofVec2f& _value)
{
float wox = _value.x;
float woy = _value.y;
int woxi = (int)(wox * 10.0f);
int woyi = (int)(woy * 10.0f);
_value.x = (float)woxi / 10.0f;
_value.y = (float)woyi / 10.0f;
waveOrigin.set(_value);
}

I went and set a breakpoint to see if it got in the function, and it does perform that function. However, it does not update the GUI.

UPDATE: I figured it out, you can’t get edit values of a ofParameter from it’s listener function. Makes sense, really.