How to get the String from the Row that I clicked ? (ListBox)



I am beginner in Juce and maybe this is a stupid question.

I made a ListBox which is displaying the name of “sytems” which are connected to my computer.
Those systems have a specific name that I am displaying with the ListBox.

For example:

I connect name 1, name 2 and name 3 to my computer.
then in my list I have:

name 1
name 2
name 3

After that if I disconnect name 2
We can see:

name 1
name 3

In my case I would like to implement functions which are dependant of the name.
If I clicked on name 1, the function 1 will be executed.

I don’t know how to get the String from the Row that I clicked ?

Do you know what is the best way to solve my problem?

I cannot use Row number to do that because as I shown to you in my example name 3 at the begining is Row=2 and when I disconnect the name 2 the Row’s name 3 become Row=1

Thank you very much


You can use ListBox::getComponentForRowNumber() --but read the API Docs for that method… it may return nullptr if the row isn’t visible.