Value Listener for Array elements


#1

Hi there,

I have an Array held in some GUI class whose elements gets updated on user component changes.

I have another class listening for changes in this array which seems to only work if I declare a Value for each element in the Array as a member and make this array as a “Array< Value >”.

Is there another approach to this because the number of elements in this Array must be set by the user - variable.

I’d like to avoid using button attachments as the Array is changed via mouse interaction on components. That is, I only need one listener for many components that change their corresponding element in the array.
p.s. I’m no advanced programmer.

Many thanks in advance.


#2

https://juce.com/doc/tutorial_audio_processor_value_tree_state
contains all the concepts you’re looking for. adapt the concepts to your needs.


#3

I have already looked into this.
But I don’t know how to get this to listen to an array.
This tutorial only covers how to have this listen to pre-made attachment objects.


#4

don’t use an array. use a ValueTree to hold your values.


#5

https://juce.com/doc/classValueTree


#6

That’s it, exactly where I should have been looking as the tutorial does more than I need.
Many thanks for your help!