ListBox item selected


What I’ve done is override the virtual function listBoxItemClicked() in ListBoxModel class.

The problem is now, that because I’ve overloaded the function, I cannot get the rows to highlight when I click on them. I tried adding a line like this to do the default actions after the overloaded instructions:

// call base function this->ListBoxModel::listBoxItemClicked(row, e);

Still did not highlight a row when I selected it.

All I want is that when I click on a row, additional things occur (i.e. populate certain TextEditors) however I still need the row to highlight. Any ideas?


you’ve done something wrong somewhere else.

I’m pretty sure ListBoxModel::listBoxItemDoubleClicked() is an empty method[1], so overriding it will have no effect on the base model behaviour.

What else have you overriden? Do you do any funky autoselection of list entries that could be going wrong?

[1] unless this has changed in 1.40 - I’m using 1.39 still.


Yeah, that’s an empty base class method so can’t be the problem here.


the causes could be multiple, but mainly:

(1) in:

void paintListBoxItem (int rowNumber,
                       Graphics& g,
                       int width, int height,
                       bool rowIsSelected)

you are not painting the row with a different colour when “rowIsSelected” is true.

(2) if you override:

void selectedRowsChanged (int lastRowSelected)

remember to call “list->repaint();” before return.

(3) when u changethe list content, are you calling “list->updateContent()” (when needed) ?

hope this helps !