Array of Buttons


#1

Hi,

I need to create a array of buttons with 8 columns and 5 lines, a total of 40 buttons.

How can I make them and create listeners thats will lead to only one "buttonThatWasClicked" ?

Do I have to create 40 buttons, one by one ?

Paulo


#2

Use an OwnedArray of Buttons then create them in your constructor in a loop and add them to the parent’s listener list.

There are a number of ways you can identify which button was pressed in the listener callback, probably the easiest would be to name the buttons with incremental ID’s

Rail


#3

Thank you for your reply Rail

Is it asking to much to give me one example ?

Thanks,

Paulo


#4

There's a near exact example of what you want to do in the JUCE demo "Timers & Events" page. Take a look at the code and just substitute FlashingComponent for TextButton or whatever you want to display. It also has a lot of listener examples.


#5

Thank you dave and Rail