How to edit tooltip labels (custom parameters)?

Hi Everyone,

I am wondering something here and maybe someone can help me out on this one:

I have a selector knob that selects 0, 1 and 2, for example. So I want to have the selector’s tool tip text be like: “0-Saw”, “1-Triangle”, “2-Square”, depending on the currently selected option. Instead of just showing 0, 1 and 2. Can it be done? Could someone maybe point me to that direction or maybe some example?

Thanks you all very much, Marcelo.

Hello Marcello,

Have a look at ParamQuantity::setDisplayValueString(), didn’t try it yet but I think it should allow you to set the tooltip label in any way you want. From the module struct, something like paramQuantities[PARAM_ID].setDisplayValueString("Square")maybe

There is a detailed thread here where @Vortico explains the correct way to do this. Configuring custom parameter display in v1

Done this on my LFO module like so:

You can of course set any range you wish. You’ll still be able to input numbers also just returns a string when the param value hits a certain range.

Original discussion:

Thanks a lot guys, with the tips from here I was able to implement.

Thank you very much, Marcelo.

This is an old posting, and I’m fairly certain that this has changed in V2. Could someone post an example of how to do this with the more modern SDK? I’d be very interested in learning! Thanks!!

There are multiple ways to achieve this.

  • Use configSwitch() to configure the param. Yes, you can use configSwitch for a knob. It’s not just for things that look like switches. :-).

If don’t have static descriptions of the values as in configSwitch, and you need something more dynamic:

[edit: removed bogus method that doesn’t exist]

  • Subclass ParamQuantity and override getDisplayValueString.
  • Without making a derived class, you can pq->setDisplayValueString.

When manipulating the value string, the tip is prepended by the name of the param. To change the name, just set the name member.

When making a ParamQuantity subclass it often makes sense to make a companion configMyParam template to configure it.

2 Likes

I gave this a shot based on your answer:

paramQuantities[SHAPE_KNOB]->setDisplayValueString("foo");

But it didn’t seem to work. Any suggestions?

Here’s my entire test:

        
configParam(SHAPE_KNOB, 0.0f, (NUMBER_OF_PLAYBACK_MODES * 2) - 1, 0.0f, "Shape");
paramQuantities[SHAPE_KNOB]->snapEnabled = true;
paramQuantities[SHAPE_KNOB]->setDisplayValueString("foo");

I realize that I already set the name to “Shape”, but I expected the setDisplayValueString call to overwrite the initial value.

When I tried setDisplayString, I got an error:

error: ‘struct rack::engine::ParamQuantity’ has no member named ‘setDisplayString’; did you mean ‘setDisplayValueString’?

Thanks!

1 Like

Abject apologies for mentioning a method that doesn’t exist. Edited the post. My eyes must have been bleary from a long day at the computer. Fall of next year I’m probably having cataract surgery.

1 Like

Did you ever get this to work? I’m coding my first module and trying (and failing) to put some custom text on the tooltip of a knob…

Hey Alex, don’t know if it would help you, but recently I needed to add custom tooltip to port, relevant code is here. In short, I had to create custom component and overwrite hover/tooltip behaviour.

Tooltip is the name you configure for the param. That might be enough. Otherwise you can create a subclass and override one of the display… methods.

And I can tell you it is a big pain to do that. But I’ve certainly done it only plenty of modules. Why it couldn’t be overridden with a lamba rather than subclassing I don’t now…

Yeah, I was able to change the name fairly easily, but unable as of yet to override the display of numbers being output from the knob. I have yet to try to implement @Cella’s code - this module is my first C++ coding project and that code is currently a little beyond my comprehension :slight_smile: But a good learning opportunity!

I’m coding a simple LFO, and on the rate knob, at certain values, I want it to display “1 hour”, “6 hours”, or “1 day” instead of “143.5” or what have you.

For this, you must make a class derived from ParamQuantity that does your custom formatting in an override for std::string getDisplayValueString().

Best experience is if you can parse your formatted value back to float by overriding void setDisplayValueString(std::string s)

For a simple example of deriving from ParamQuantity for displaying/parsing something other than a float, look at the implementation of Rack’s SwitchQuantity. This is why I recommend cloning and building Rack, so that you have the source and can see how things are done, and even step through in a debugger.

I have found that I sometime also need to pair a custom ParamQuantity with a custom knob or button to present a better menu - just to have an organized hierarchy for a control that sets options, rather than just having a long menu. Rack’s menus aren’t very usable when they’re long.

2 Likes

So you want a lambda-configurable ParamQuantity. Off the top of my head:

struct LambdaExtensibleParamQuantity : ParamQuantity{
    using Base = ParamQuantity;

    std::function<std::string(float)> custom_get_string{nullptr};
    std::function<float(std::string)> custom_set_string{nullptr};

    std::string getDisplayValueString() override {
        if (custom_get_string) {
            return custom_get_string(getValue());
        }
        return Base::getDisplayValueString();
    }
    void setDisplayValueString(std::string s) override {
        if (custom_set_string) {
            setValue(custom_set_string(s));
        }
        Base::setDisplayValueString(s);
    }
    void configLambdas(std::function<std::string(float)> get, std::function<float(std::string)> set) {
        custom_get_string = get;
        custom_set_string = set;
    }
};
3 Likes