Multiple selection and right click on TableListBox


#1

Hi Jules,

A happy new year.

When multiple rows on the TableListBox are selected and right click one of them, other rows are de-selected before TableListBoxModel::cellClicked() is called.

I think this is not good behavior when the application need to do the action for selected rows by right click.

How about changing return type of TableListBoxModel::cellClicked() to bool instead of void? If the return value is true, TableListBox won’t change the row selection if the clicked row was selected, etc.

Best regards,
Masanao Hayashi


#2

Happy new year!

Good point… I think the best fix would be this tweak to juce_ListBox.cpp:

void ListBox::selectRowsBasedOnModifierKeys (const int row, const ModifierKeys& mods) { if (multipleSelection && mods.isCommandDown()) { flipRowSelection (row); } else if (multipleSelection && mods.isShiftDown() && lastRowSelected >= 0) { selectRangeOfRows (lastRowSelected, row); } else if (! mods.isPopupMenu()) { selectRowInternal (row, false, true, true); } }


#3

Thanks!

I think this one is more better, it gives us the same behavior as Mac OS X Finder, iTunes and Windows Explorer, etc.

void ListBox::selectRowsBasedOnModifierKeys (const int row, const ModifierKeys& mods) { if (multipleSelection && mods.isCommandDown()) { flipRowSelection (row); } else if (multipleSelection && mods.isShiftDown() && lastRowSelected >= 0) { selectRangeOfRows (lastRowSelected, row); } else if ((!mods.isPopupMenu()) || (!isRowSelected(row))) { selectRowInternal (row, false, true, true); } } [/quote]


#4

ah yes, that’s even better.


#5

Thanks. :slight_smile:
Could you choose this solution in JUCE v1.46?

  • Masa

#6

Yes, no problem.