Controlling a parameters from ofxGui AND some kb shortcut

Hi all,
is the above possible?
I want to be able to have some nice gui sliders for general access,
but I would also like to be able to alter some of these parameters by assigning keyboard shortcuts.

The problem is I can not use arithmetic operators on values that are assigned by the sliders (+ , _ , * , / , = )… so I can notassign a nice value to an ofxSlider class (say ofxIntSlider).

How can I do that?

thank you in advance for your help!

I recently did this - it was pretty tricky. The key is that the ofParameterGroup is “owned” by the ofxGui so you have to get to that.

The way I did it was:

ofParameterGroup* guiParamGroup;

guiParamGroup = (ofParameterGroup*)&gui.getParameter();

and then later


All of this stuff is in this work-in-progess project if you want to look around

hi jvcleave and thank you for the help.
I am trying the /examples/gui/guiExample.
with your help, I went as far as repeating your code.

void ofApp::keyPressed(int key){

    if(key == '+'){
            ofParameterGroup* guiParamGroup;
            guiParamGroup = (ofParameterGroup*)&gui.getParameter();
            int i = guiParamGroup->get("circleResolution").cast<int>();

            guiParamGroup->get("circleResolution").cast<int>() =  \
            guiParamGroup->get("circleResolution").cast<int>() + 2;

This is fine , but I wonder if I could access directly the ofParameter instead of going through ofParameterGroup. I can’t try it out now, but I think (reading through your project) that the following should work, too ?

    if(key == '+'){
            ofParameter<int>* guiParam;
            guiParam = (ofParameter<int>*)&circleResolution.getParameter();
            int i = guiParam->cast<int>();

I think that is just going to read/copy the value

which is what I want :smile:

I verifed this and it works. I can alter the value if I append to the above

guiParam->cast<int>() += 2 ;  

Thank you for the info!

I also needed to access the ofParameter contained within the ofxIntSlider to make it a dynamic slider.
I fixed it by doing this:

//ofxIntSlider slider; // (already assigned)
ofParameter<int> tmp;
tmp = slider;

Now you can do tmp.setMax(), tmp.setMin(), etc.

Thanks a ton Daan. Not entirely sure how that works, but it works great.