Custom listbox and row number


#1

I have a custom list box with checboxes inside it. I want to get Components which are selected. The idea is simple - to get all component and to check which of them have checked state.
The problem is that I cannot get all components, and I even cannot get total number of ones.

returns 1, but I have 6 items. The private field named

has correct value = 6 though. What’s wrong with getNumChildComponents() ?


#2

What about getSelectedRows() ?


#3

ok, say if checkbox in the item is toggled then set it selected. But how to set a row into selected state from inside item component? anyway, what’s with totalItems


#4

Have your items pass state changes messages back to the model, and let the model keep track of the overall state.


#5

I did this:

m_productsListBox->updateContent(); for(int i = 0; i < productDTOs.size(); ++i) { m_productsListBox->selectRow(i); m_productsListBox->getModel()->selectedRowsChanged(i); }

but

gives me 1 instead of 6


#6

http://www.rawmaterialsoftware.com/juce/api/classListBox.html#ac56613db03adf964a683e184f7248640

Note the third parameter!


#7

[quote=“valley”]http://www.rawmaterialsoftware.com/juce/api/classListBox.html#ac56613db03adf964a683e184f7248640

Note the third parameter![/quote]
it helped. Thank you