Adding support for using shift key with rubberband for adding a group of elements to the current selection
authorlaurent
Sun, 08 Jan 2012 19:29:45 +0100
changeset 620 f0232cd1628d
parent 619 fc03645162b5
child 621 084a21799803
Adding support for using shift key with rubberband for adding a group of elements to the current selection
Viewer.py
--- a/Viewer.py	Sun Jan 08 19:28:00 2012 +0100
+++ b/Viewer.py	Sun Jan 08 19:29:45 2012 +0100
@@ -1421,6 +1421,9 @@
                     elif len(elements) == 1:
                         self.SelectedElement = elements[0]
                     self.SelectedElement.SetSelected(True)
+                else:
+                    self.rubberBand.Reset()
+                    self.rubberBand.OnLeftDown(event, dc, self.Scaling)
             else:
                 element = self.FindElement(event)
                 if not self.Debug and (element is None or element.TestHandle(event) == (0, 0)):
@@ -1494,14 +1497,22 @@
         self.StartMousePos = None
         if self.rubberBand.IsShown():
             if self.Mode == MODE_SELECTION:
-                elements = self.SearchElements(self.rubberBand.GetCurrentExtent())
+                new_elements = self.SearchElements(self.rubberBand.GetCurrentExtent())
                 self.rubberBand.OnLeftUp(event, self.GetLogicalDC(), self.Scaling)
-                if len(elements) == 1:
-                    self.SelectedElement = elements[0]
+                if event.ShiftDown() and self.SelectedElement is not None:
+                    if isinstance(self.SelectedElement, Graphic_Group):
+                        elements = self.SelectedElement.GetElements()
+                    else:
+                        elements = [self.SelectedElement]
+                    for element in elements:
+                        if element not in new_elements:
+                            new_elements.append(element)
+                if len(new_elements) == 1:
+                    self.SelectedElement = new_elements[0]
                     self.SelectedElement.SetSelected(True)
-                elif len(elements) > 1:
+                elif len(new_elements) > 1:
                     self.SelectedElement = Graphic_Group(self)
-                    self.SelectedElement.SetElements(elements)
+                    self.SelectedElement.SetElements(new_elements)
                     self.SelectedElement.SetSelected(True)
             else:
                 bbox = self.rubberBand.GetCurrentExtent()