# TableListBox Multi selection behavior broken?

**URL:** <https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119>\
**Category:** General JUCE discussion\
**Created:** [December 31, 2010, 3:00pm UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119 "2010-12-31T15:00:22Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [December 31, 2010, 3:00pm UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119/1 "2010-12-31T15:00:22Z")

</div>

Hi Jules,

I’m seeing something unusual which I think didn’t use to happen in previous version.

If you enable multi selection in the TableListBox, then select multiple items, clicking on an item of this selection won’t change the selection.  
This is quite annoying especially if all items are selected and if you don’t have an empty space in the list to un select everything.

Was this intentional ?

Thanks,

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [January 1, 2011, 3:34pm UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119/2 "2011-01-01T15:34:58Z")

</div>

No, not intentional, I’ll take a look and see what I can do…

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [January 3, 2011, 11:49am UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119/3 "2011-01-03T11:49:08Z")

</div>

Don’t know if the latest commit regarding TableListBox should have fixed this, but it’s still happening.

Thanks,

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [January 3, 2011, 11:56am UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119/4 "2011-01-03T11:56:06Z")

</div>

Yes, I fixed it, and it works fine in the juce demo… (?)

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [January 3, 2011, 12:59pm UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119/5 "2011-01-03T12:59:45Z")

</div>

Works fine now.  
I had to update my proxy to forward event when an item was a label for mouseUp as well.

Thanks,

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [March 21, 2011, 11:29am UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119/6 "2011-03-21T11:29:59Z")

</div>

Hi Jules,

It seems this is broken again using command key to select multiple row

Both mouseDown and mouseUp call selectRowsBaseOnModifierKeys which call flipRowSelection,  
so on mouse down it selects the row and on mouse up it deselect it.

Thanks,

---

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [March 21, 2011, 1:58pm UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119/7 "2011-03-21T13:58:15Z")

</div>

I just wanna throw this out there now, but regarding the multi-select code for ListBox - while functional, does not efficiently support lists with hundreds of thousands or millions of rows.

There are methods of implementation, using a small amount of caller-provided storage for each row, that allow typical operations to execute in O(1) instead of O(n). For example, select all, deselect all, adding or removing a row from the selection, or determining if a row is selected, can all execute in O(1) if we allow for a bit of extra storage per row (two integers and a pointer).

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [March 23, 2011, 9:32am UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119/8 "2011-03-23T09:32:24Z")

</div>

Bump (regarding the broken multi selection)

Thanks,

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [March 23, 2011, 10:45am UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119/9 "2011-03-23T10:45:14Z")

</div>

Sorry, I hadn’t noticed your post! Will take a look today.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [March 23, 2011, 12:48pm UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119/10 "2011-03-23T12:48:45Z")

</div>

> [@](#):
>
> Both mouseDown and mouseUp call selectRowsBaseOnModifierKeys which call flipRowSelection, so on mouse down it selects the row and on mouse up it deselect it.

erm… no, it seems to be working fine for me (?)

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [March 23, 2011, 1:30pm UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119/11 "2011-03-23T13:30:12Z")

</div>

Just checked the demo and indeed it works fine in the demo.

There is something I don’t get looking at the code though

DummyTableListBoxComponentWrapper::mouseDown  
calls selectRowsBasedOnModifierKeys  
when isCommandDown is true then it call flipRowSelection  
the row is not yet selected so it calls selectRowInternal  
the row is now selected

now on DummyTableListBoxComponentWrapper::mouseUp  
it calls selectRowsBasedOnModifierKeys  
when isCommandDown is true then it call flipRowSelection  
and as the the row is selected it calls deselectRow

Am i missing something ?

Thanks,

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [March 23, 2011, 2:08pm UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119/12 "2011-03-23T14:08:37Z")

</div>

I don’t understand what you’re referring to…? What’s “DummyTableListBoxComponentWrapper”?

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [March 23, 2011, 2:48pm UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119/13 "2011-03-23T14:48:40Z")

</div>

oh I see the issue might be in my code then 😃

I’ve create a dummy wrapper around custom editor component in the tableList box so it selected when you click those editors as well.  
look like my fowards to achieve this behaviour are wrong

What would be the best way to achieve this ?

For example you have a combobox in the TableListBox and you want that the selection in the combobox select the row where the combo box is.

Thanks,

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [March 23, 2011, 4:18pm UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119/14 "2011-03-23T16:18:04Z")

</div>

Just do it in TableListBoxModel::selectedRowsChanged() ?

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [March 23, 2011, 4:20pm UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119/15 "2011-03-23T16:20:03Z")

</div>

I meant to forward the mouse click event which is not catch by the RowComponent but by the custom component in the column.

Thanks,

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [March 23, 2011, 4:32pm UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119/16 "2011-03-23T16:32:55Z")

</div>

Hmm, not sure. You could probably use addMouseListener to get the event, and just select the row.

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [March 23, 2011, 4:34pm UTC](https://forum.juce.com/t/tablelistbox-multi-selection-behavior-broken/6119/17 "2011-03-23T16:34:42Z")

</div>

oki doki
