Updating ChoicePropertyComponent

What is the preferred way to update the choices in a ChoicePropertyComponent when they change?

I’ve tried subclassing the getChoices method but it’s doesn’t seem subclassable as my method never gets called.

Any ideas?

The answer seems to be, to change the StringArray choices that was used to construct the ChoicePropertyComponent and then call the component’s refresh() method.

Changing the choices StringArray does not seem to work. The choices StringArray inside the component is just a copy of the one you pass, so updating it externally has no effect.

Even a subclass has no access to choices or the comboBox because they are private.

So what to do?

It is even worse, because changing the combobox is only half of the goal. You need to change the RemapperValueSource as well:

So with the current implementation it seems to me you can only destroy the component and recreate it.

Yeah, it’s been a while since I messed with the ChoicePropertyComponent class… but I believe I ended up adding some additional methods to the class to make it easier to change Sections and Components…

Rail

That’s what I ended up doing, destroying the entire panel with sections and rebuilding.
Very un-Juce like.