How to Store a String in a Preset for popupMenuItems Instead of a Numeric Value?
-
I want to save the selected item’s string (name) in a preset rather than its numeric index value from a panel’s popup menu. How can I achieve this?
-
@bendurso What do you want to do with the string?
-
@d-healey I want to store the selected expansion. And I don't know how many expansions have the user installed, so the number value won't work.
-
@bendurso But won't the preset be within an expansion?
-
@d-healey I want to include samplemaps from other expansions, and is possible :)
-
@bendurso Perhaps the simplest way would be to use a hidden label with saveInPreset enabled?
-
@bendurso said in How to Store a String in a Preset for popupMenuItems Instead of a Numeric Value?:
I want to save the selected item’s string (name) in a preset rather than its numeric index value from a panel’s popup menu. How can I achieve this?
So.. the way I do this, after a lot of to-ing a fro-ing over the years, and this is because I want to add additional values into my combo box - like a drop down to select FX and the numbering system of combo-boxes wont work - unless I add every new FX at the end of the list - and who wants that?
I add a LAF to the combo box - that shows blank for the selected value, but does nice LAFy things with the drop down listing when its showing, and I make sure saveInPreset is disabled
In the Call back it populates a label that sits behind the combo box with its text (comboBox.getItemText() .... and calls changed on the text label....
The text label is responsible for the action - in my case loading the correct FX into the slot.
Here's what it looks like:
that "CHORUS" in blue - thats a label, that has been tweaked to look like a combo box...there is a combo-box right there - but its default display is set to blank....
If this whole thing was just a combo-box and now I want to add (say) a thru zero flanger to my list of modulation effects, right after "FLANGER" - well I could just do that - but now every existing preset the user has would be wrong (off by 1) for all cases where they had loaded an FX that was listed after the FLANGER
In essence Im fast coming to the conclusion for long term expandability - fx, filters etc. saving anything in a combo-box value is a bad idea...
-
-
@bendurso said in How to Store a String in a Preset for popupMenuItems Instead of a Numeric Value?:
I don't know if it makes sense to make a request in Hise to store Strings as an option in comboboxes or panels, in adittion to numbers.
Well its an either or thing - what if the number stored doesnt match the text what should it do then?
Plus it would break every existing preset in every HISE product that ever used a combobox...
so Im guessing Christophs answer would (rightly) be a big fat no .... its really up to you to do the work if you want it expandable in the long term.
-
@Lindon I was referring to a toggle option, like "Use strings instead of numeric values." So instead of looking for numbers, it would look for and save string values instead. This would only work when it’s enabled, so it won’t break any existing plugins.
But it was just an idea; maybe it doesn’t really make sense.