DSVColumnView.st
changeset 2907 c4a8cac87053
parent 2886 c7dd9972a292
child 2933 ab7be1db710d
--- a/DSVColumnView.st	Fri Feb 03 12:37:39 2006 +0100
+++ b/DSVColumnView.st	Tue Feb 07 19:04:19 2006 +0100
@@ -2051,7 +2051,7 @@
     isSelected         := self isInSelection:aStartRow.
 
     isSelected ifTrue:[ self removeRowFromSelection:aStartRow ]
-              ifFalse:[ self addRowToSelection:aStartRow ].
+              ifFalse:[ Transcript show:'add:';showCR:aStartRow. self addRowToSelection:aStartRow ].
 
     multipleSelectOk ifFalse:[ ^ self ].
 
@@ -2059,9 +2059,10 @@
     chgSet := IdentitySet new.
     doAdd  := isSelected not.
 
-    buttonMotionAction := [:p| |rowNr mustRestore step f|
+    buttonMotionAction := [:p| 
+        |rowNr mustRestore step f|
+
         rowNr := self yVisibleToRowNr:(p y).
-
         (rowNr notNil and:[rowNr ~~ prvRow]) ifTrue:[
             rowNr == aStartRow ifTrue:[
                 mustRestore := true
@@ -2071,6 +2072,9 @@
             ].
             prvRow > rowNr ifTrue:[ step := -1 ]
                           ifFalse:[ step :=  1 ].
+
+
+Transcript showCR:mustRestore.
             mustRestore ifTrue:[
                 [ prvRow ~~ rowNr ] whileTrue:[
                     (chgSet removeIdentical:prvRow ifAbsent:nil) notNil ifTrue:[
@@ -2143,7 +2147,8 @@
 buttonPress:button x:x y:y
     "a button was pressed - handle selection here"
 
-    |oldView rowNr colNr firstRowNr menu sensor clickPoint clickedIntoSelection|
+    |oldView rowNr colNr firstRowNr menu sensor clickPoint clickedIntoSelection
+     motionSelectAction|
 
     clickPoint := x @ y.
     oldView    := editView.
@@ -2204,21 +2209,6 @@
         ^ self.
     ].
 
-    clickedIntoSelection ifTrue:[
-        self canDrag ifTrue:[
-            buttonMotionAction := [:p|
-                self canDrag ifTrue:[
-                    (((p x dist:clickPoint x) > (UserPreferences current motionDistanceToStartDrag))     
-                    or:[p x < -5 or:[p x > (width+5)]]) ifTrue:[     
-                        buttonReleaseAction := buttonMotionAction := nil.
-                        self startDragAt:p
-                    ]
-                ].
-            ].
-        ].
-        ^ self.
-    ].
-
     buttonMotionAction := [:p|
         |r2|
 
@@ -2227,7 +2217,17 @@
                 r2 := self yVisibleToRowNr:(p y).
                 r2 notNil ifTrue:[
 "/                    r2 ~~ self lastIndexSelected ifTrue:[
-                        self selectRowFrom:firstRowNr to:r2.
+                        sensor ctrlDown ifTrue:[
+                            firstRowNr to:r2 do:[:rowToToggle |
+                                clickedIntoSelection ifTrue:[       
+                                    self removeRowFromSelection:rowToToggle
+                                ] ifFalse:[
+                                    self addRowToSelection:rowToToggle
+                                ]
+                            ].
+                        ] ifFalse:[
+                            self selectRowFrom:firstRowNr to:r2.
+                        ].
                         clickPoint := p.
 "/                    ].
                 ].
@@ -2242,6 +2242,23 @@
             ]
         ].
     ].
+
+    clickedIntoSelection ifTrue:[
+        self canDrag ifTrue:[
+            motionSelectAction := buttonMotionAction.
+            buttonMotionAction := [:p|
+                self canDrag ifTrue:[
+                    (((p x dist:clickPoint x) > (UserPreferences current motionDistanceToStartDrag))     
+                    or:[p x < -5 or:[p x > (width+5)]]) ifTrue:[     
+                        buttonReleaseAction := buttonMotionAction := nil.
+                        self startDragAt:p
+                    ] ifFalse:[
+                        motionSelectAction value:p
+                    ].
+                ].
+            ].
+        ].
+    ].
 !
 
 buttonRelease:button x:x y:y
@@ -3525,10 +3542,12 @@
         self selectColIndex:0 rowIndex:aRowNr.
         ^ self
     ].
-    (self isInSelection:aRowNr) ifTrue:[^ self].
+    (self isInSelection:aRowNr) ifTrue:[
+        ^ self
+    ].
 
     multipleSelectOk ifFalse:[
-        self selectColIndex:0 rowIndex:aRowNr.    
+       self selectColIndex:0 rowIndex:aRowNr.    
         ^ self
     ].
     newSelection := selectedRowIndex copyWith:aRowNr.
@@ -3536,7 +3555,7 @@
     selectedColIndex ~~ 0 ifTrue:[
         self selectColIndex:0 rowIndex:newSelection.
     ] ifFalse:[
-        selectedRowIndex := selectedRowIndex copyWith:aRowNr.
+        selectedRowIndex := newSelection.
         self invalidateRowAt:aRowNr.
         self selectionChanged.
     ].
@@ -4110,5 +4129,5 @@
 !DSVColumnView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.209 2006-01-23 22:18:58 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.210 2006-02-07 18:04:19 cg Exp $'
 ! !