class: SelectionInListView
authorClaus Gittinger <cg@exept.de>
Mon, 09 Sep 2013 12:50:53 +0200
changeset 4758 734f7f03e95c
parent 4757 408fa0d269bf
child 4759 c89c752d03f8
class: SelectionInListView changed: #expandSelectionToX:y: #sizeChanged: shift-click: fixed expand-selection to handle the case, were no click was done before (i.e. selection comes from program).
SelectionInListView.st
--- a/SelectionInListView.st	Mon Sep 09 10:53:52 2013 +0200
+++ b/SelectionInListView.st	Mon Sep 09 12:50:53 2013 +0200
@@ -2672,14 +2672,14 @@
 !
 
 sizeChanged:how
-    "if there is a selection, make certain, its visible
+    "if there is a selection, make certain, it is visible
      after the sizechange"
 
     |first wasAtEnd selectionWasWisible oldFirst|
 
     widthOfWidestLine := nil.
     oldFirst := firstLineShown.
-    wasAtEnd := (firstLineShown + nFullLinesShown) >= self size.
+    wasAtEnd := (nFullLinesShown < list size) and:[ (firstLineShown + nFullLinesShown) >= list size ].
 
     selectionWasWisible := false.
     selection notNil ifTrue:[
@@ -2712,7 +2712,7 @@
             ]
         ] ifFalse:[
             "
-             if we where at the end before, move to the end again.
+             if we were at the end before, move to the end again.
              Still to be seen, if this is better in real life ...
             "
             wasAtEnd ifTrue:[
@@ -3487,11 +3487,27 @@
 
     |movedLine delta newSelection|
 
-    clickLine isNil ifTrue:[^ self].
-    self multipleSelectOk ifFalse:[ ^ self].
+    self multipleSelectOk ifFalse:[^ self].
 
     movedLine := self visibleLineToAbsoluteLine:(self visibleLineOfY:y).
 
+    clickLine isNil ifTrue:[
+        selection size == 1 ifTrue:[
+            clickLine := selection first.
+        ] ifFalse:[
+            movedLine > selection max ifTrue:[
+                clickLine := selection max
+            ] ifFalse:[
+                movedLine < selection min ifTrue:[
+                    clickLine := selection min
+                ].
+            ]
+        ].
+        clickLine isNil ifTrue:[
+            ^ self
+        ].
+    ].
+
     selectionAtClickTime isNil ifTrue:[
         selectionAtClickTime := selection copy.
     ].
@@ -3507,7 +3523,7 @@
         doSelect := doUnselect := false.
 
         isSelected := self is:ln inSelection:selectionAtClickTime.
-        selectMode == true ifTrue:[
+        (selectMode ? true) == true ifTrue:[
             doSelect := isSelected not
         ] ifFalse:[
             selectMode == false ifTrue:[
@@ -4121,10 +4137,10 @@
 !SelectionInListView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.270 2013-09-02 15:12:07 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.271 2013-09-09 10:50:53 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.270 2013-09-02 15:12:07 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.271 2013-09-09 10:50:53 cg Exp $'
 ! !