[BUG] About Attachments and Notifications


#1

Hello there,
I see that in juce_AudioProcessorValueTreeState.cpp every attachment implementation triggers a synchronous notification when its setValue() is called.
E.g. for the ComboBox:

void setValue (float newValue) override
{
    combo.setSelectedItemIndex (roundToInt (newValue), sendNotificationSync);
}

Is this intentional? Shouldn’t these interactions use dontSendNotification instead?
The current behaviour makes it impossibile to distinguish between user interactions and other kinds of interactions with the linked widget.
For instance, let’s say I want to use an attachment to control a parameter and automagically update the widget’s UI, but I also want to register the widget’s parent Component as a Listener (e.g. ComboBox::Listener) in order to perform some actions only when the user interacts with it.
With the current state of the art I can’t, because right in the constructor, each attachment calls sendInitialUpdate(), which ends up calling setValue(), triggering all widget’s listeners.

I’ve created my own custom attachments to circumvent this, but it would be great if you could either change such behaviour or let us decide the type of notification to be used.
Maybe something like this:

ComboBoxAttachment (AudioProcessorValueTreeState& stateToControl,
                    const String& parameterID,
                    ComboBox& comboBoxToControl,
                    NotificationType notification = sendNotificationSync);

Thanks for reading!