At some point in version 6 our ChoicePropertyComponents which are connected via ValueObjects to our apps configuration stopped working.
It’s a complete maze of Value objects and every time I try a different version takes several minutes to rebuild the app. So it’s tricky to work out what’s going on.
The problem seems to arise when the Value object is originally an empty string, which isn’t a choice. It then seems impossible to get it to set the Value to any valid selection when using the UI.
Checking out the version of juce_ChoicePropertyComponent.* from version 6.0.1 restores the correct behaviour.
There have only been a couple of changes to the ChoicePropertyComponent since 6.0.1:
Could you try building your project with each of these versions of the ChoicePropertyComponent and find which version introduces the issue? If you’re able to provide a very minimal example project which demonstrates the problem that would also help us to track the bug down.
The Projucer uses ChoicePropertyComponents. Both of the ChoicePropertyComponent changes above were made to fix issues that were affecting the Projucer. Perhaps you could try reproducing your issue in the Projucer to save you some typing.
class MainComponent : public juce::Component, public Value::Listener
{
public:
MainComponent()
{
setSize (400, 200);
addAndMakeVisible (panel);
// with this line in place and JUCE 6.0.8 the listener is never called when the user changes the combo box
v = String();
// but with this next line enabled it will work
// v = 0;
v.addListener(this);
Array<PropertyComponent*> properties;
properties.add (new ChoicePropertyComponent (v, "Property", { "A", "B" }, { 0, 1 }));
panel.addProperties (properties);
}
void valueChanged(Value &) override
{
DBG("working: value is now " + v.getValue().toString());
}
~MainComponent() override = default;
void paint (juce::Graphics& g) override { g.fillAll (Colours::black); }
void resized() override { panel.setBounds (getLocalBounds()); }
private:
Value v;
PropertyPanel panel;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
};