ofParameter listener trigger once

hello,

I am using an event listener of an ofParameter to trigger an action when a button is on or off.

I have just noticed that the event is always triggered while i would like it to be triggered only once when the button switches state.

is that possible ? is there a mean to change this behavior ?

thanks

can you post an example? it’s not very clear what’s the problem

yes sure !
I will try to be more specific…

so i have a bool parameter :

ofParameter<bool> bEmit;

I add a listener :

bEmit.addListener(this, &ofApp::onEmit);

when the event is triggered, this fires this function :

void ofApp::onEmit(bool &val) {
    if (val) {
        particleWidth = 2;
    }
}

where where particleWidth is an ofParameter<int>

So here when bEmit is off, i can vary the slider particleWidth.
When bEmit is on, particleWidth is 2 no matter what.

So i guess particleWidth = 2 is fired as long as bEmit button is on when i expected it would be fired once when button switches from off to on.

does it make sense ?

not sure if i’m understanding it correctly but onEmit will only be fired when bEmit changes.

yes, this is what i expect, but it doesn’t seem to act like so.
Maybe i did something wrong somewhere…

what do you mean by always, every frame? the way ofParameter works it’s impossible that it’ll trigger an event on it’s own without it’s value being set

yes it seems it is fired every frame…
Ok so i will investigate more deeply to see if there is something wrong in my code.

thanks a lot