PDA

View Full Version : Multiple rubber band selections?



s7
9th August 2012, 22:35
Hello, I have a rubber band selection enabled in my application and similar to adding new items to the selection via CTRL+Click, I would like to add multiple items with another rubber band to the existing group of selections -e.g. when I press shift, hold it, and use mouse to select another group of items, they should also be added to my current selection- what would be the best way to do this? I'm thinking of adding a SHIFT key event modifier check and do it there but I couldn't figure out how to connect the new rubber band selection with the previous one -maybe using the initial list of selected items and appending them to the current selected ones under that if check for shift key?- Thanks.

d_stranz
11th August 2012, 01:23
Somewhere in the class that handles the mouse actions, you need to save the initial selection list. The next time selection occurs, you must check for the SHIFT key (or whatever you decide to use to indicate extended selection) and set a flag that tells the rubberband code to append to the current list (SHIFT pressed) or discard the current list and replace it with the new selection (no SHIFT pressed).

You should also consider handling the ESC key to cancel the selection mode to allow the user to get out without destroying the initial selection.