ImageButton onlick > setValueNotifyingHost not updating apvts in this code snippet, why?

I’ve got an ImageButton which changes the GUI size on the fly: juce::ImageButton guiresizer_button;

In my PluginEditor.cpp I have this

guiresizer_button.onClick = [this]() {  resizeTheGUI();  };

The resizeTheGUI() method sets the new size of the GUI and passes the correct float value 1.0, 2.0 or 3.0 to the method below in the audioProcessor so the apvts can be updated. (1.0 is 100% size, 2.0 is 75% size and 3.0 represents 50% size.)

Here is where I have the problem, in the audioProcessor method:

void pluginAudioProcessor::updateGUISizeValue(float newguisize)

I debugged the value of newguisize and it rotates correctly through 1.0, 2.0 or 3.0f as it should - this variable is always correct. But I debugged the apvts and this value is always 3.0f, even if newguisize is 1.0f or 2.0f

Here’s my parameter layout:

layout.add(std::make_unique<juce::AudioParameterFloat>("guiSize", "GUISize", 
  juce::NormalisableRange<float>(1.0, 3.0, 1.0, 1.0), 1.0));  //1=100%, 2=75% 3=50%

I tried setValue() instead. I tried AudioParameterInt instead of float. Still the value of guiSize in the apvts is always 3

Is it possible there’s some other method in ImageButton class that is interfering with me setting the apvts? Or is there another reason? The rest of my apvts updates fine with setValueNotifyingHost.

i’d like to encourage you to use parameter attachments for connecting gui parameters with audio processor parameters.

but if you wanna solve it the way you already do make sure to check if you beginGesture in mouseDown and endGesture in mouseUp. gestures are needed to modify parameter values

1 Like

I went the ParameterAttachment direction, and it works now…thanks ! :100:

I did try gestures first but they didn’t work for me.

1 Like