Ofxbutton + ofParameter

This isn’t working right? I think this could be included like the ofxToggle with
ofxButton::ofxButton(ofParameter< bool > _bVal, float width=defaultWidth, float height=defaultHeight)
Because ofParameterGroup’s are great!
But can it set back to zero? Maybe when the eventhandler got called once?

ofxButton is a trigger and as such it doesn’t make sense to be represented as data which is what ofParameter does. perhaps we could add the option to add an ofEvent<void>, which would be represented as a button, to a gui group since this has been raised before several times but having an ofParameter backing a button doesn’t make much sense

something that might work also is to have a specialization for ofParameter which kind of makes no sense as a parameter but might be useful for this particular case. That way if you have an ofParameter in an ofParameterGroup and pass that to a gui it’ll be rendered as a button. ping @frauzufall

I am currently faking the button by using a toggle with ofParameter and a listener function that also sets the parameter to false, but that’s not really cool.

I also like the feature to let the event that gets triggered by a button be part of a parameter group. I would still vote for ofParameter<ofEvent>. The parameter thing would make sense if you could have a button that also triggers another button if you make a reference from one parameter to the other…? Or how would that work?

the way i see it ofParameter<ofEvent<void>> doesn’t make much sense, for every other control the parameter creates an event of it’s type that you listen to:

ofParameter<float> -> ofEvent<float> (in ofxSlider)
ofParameter<bool> -> ofEvent<bool> (in ofxToggle)

so the most logical to me would be that

ofParameter<void> -> ofEvent<void> (in ofxButton)

for an ofParameter<ofEvent<void>> i would expect an ofEvent<ofEvent<void>> which wouldn’t make sense.

ofParameter<void> would be an special case where the parameter would contain no data, as its type clearly says, but still has an event like any other ofParameter that you can listen to by doing:

voidParam.addListener(voidListener);

void voidListener(){
}

which would be compatible with how ofxButton works now, that way also the getParameter() in ofxButton wouldn’t need to return an empty boolean parameter as it does now and would instead return the real parameter that triggers the event when the button is pressed

1 Like

Sounds very reasonable.

For me, that sounds great!

I am a little late with a lot of things but I can put this on my agenda. It may just take a little while.

sure no hurries, i can also look into this once we release 0.9

Hello,
I have the same issue by using ofparameters mixed with buttons, is there some news about how to do this ?
Thanks !

Sorry for the late reply.

You can now use ofParameter<void> in OF. but I think you can’t create buttons in ofxGui with them yet.

In ofxGuiExtended this is working, but it is detached from ofxGui right now.