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?
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
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!!
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.
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.
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 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.