Determining the Widget type of a Mapped Parameter

Is there any way to determine the type of a parameter mapped using the ParamHandle functionality? I’m trying to figure out a way to remotely index a switch like an SvgSwitch.

It seems like ParamQuantity doesn’t really distinguish between continuous and stepped values. I’d like a way to know whether I should set an absolute value or just increment / decrement the ParamQuantity by a specific step size.

Thanks!

Hi,

I’m not really 100% sure I understand your problem correct, but you can always figure out the real type of objects by trying to dynamic cast them to the type you expect, if there is no other way to do this in the API.

And the way to go here would be over the widget pointer of the param to investigate that you have to obtain somehow.

For example you create a method like this for detection of a SvgSwitch:

rack::app::SvgSwitch* ifIsSvgSwitch(rack::widget::Widget* widget)
{
    return dynamic_cast<rack::app::SvgSwitch*>(widget);
}

and check with something like this

auto widgetToCheck = obtainSomehowTheWidget();

auto svgSwitch = ifIsSvgSwitch(widgetToCheck);

if (svgSwitch)
{
    // do something with Svg switch
    svgSwitch->paramQuantity->setValue(1.f); 
}
else 
{
    // it is different kind of widget
}

I hope this helps.