DSVColumnView.st
changeset 1749 e78e17ead1ce
parent 1722 9972e8bb1424
child 1754 4dea21fbacee
--- a/DSVColumnView.st	Tue Mar 28 16:00:20 2000 +0200
+++ b/DSVColumnView.st	Tue Mar 28 16:09:49 2000 +0200
@@ -27,7 +27,7 @@
 		checkToggleLevel comboButtonExtent comboButtonForm
 		comboButtonLevel clickPosition dragAccessPoint dragIsActive
 		dropTarget dropSource columnAdaptor tabAtEndAction
-		tabAtStartAction modifiedChannel'
+		tabAtStartAction modifiedChannel autoScroll autoScrollBlock'
 	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
 		DefaultHilightForegroundColor DefaultHilightBackgroundColor
 		ButtonLightColor ButtonShadowColor CheckToggleActiveImage
@@ -1780,11 +1780,20 @@
     "is it the select or 1-button ?"
 
     self sensor leftButtonPressed ifFalse:[^ self].
-"/    (device buttonMotionMask:buttonMask includesButton:#select) ifFalse:[
-"/        (device buttonMotionMask:buttonMask includesButton:1) ifFalse:[
-"/            ^ self
-"/        ].
-"/    ].
+
+    autoScroll ifTrue:[
+        "/ if moved outside of view, start autoscroll
+        (y < 0) ifTrue:[
+            ^ self startAutoScroll:[self scrollUp] distance:y.
+        ].
+        (y > height) ifTrue:[
+            ^ self startAutoScroll:[self scrollDown] distance:(y - height).
+        ].
+    ].
+
+    "move inside - stop autoscroll if any"
+    self stopAutoScroll.
+
     scr := 0.
 
     y > height ifTrue:[
@@ -1801,6 +1810,7 @@
     (idx isNil or:[idx < 1 or:[self isInSelection:idx]]) ifTrue:[
         ^ self
     ].
+
     selectedRowIndex := selectedRowIndex asOrderedCollection.
 
     clickPosition notNil ifTrue:[
@@ -1920,6 +1930,8 @@
 
 buttonRelease:button x:x y:y
 
+    self stopAutoScroll.
+
     clickPosition notNil ifTrue:[
         dragAccessPoint notNil ifTrue:[
             dragIsActive ifFalse:[
@@ -2371,6 +2383,7 @@
     rowFontAscent      := 1.                            "/ dummy initialization
     separatorSize      := 1.                            "/ separators mode 2D
     selectRowOnDefault := true.
+    autoScroll         := true.
 !
 
 mapped
@@ -2950,6 +2963,44 @@
     orgY := (aPixelOffset + rowHeight - 1) // rowHeight * rowHeight.
   ^ self scrollTo:(orgX @ orgY).
 
+!
+
+startAutoScroll:aBlock distance:aDistance
+    "setup for auto-scroll (when button-press-moving below view);
+     - timeDelta for scroll is computed from distance
+    "
+    |timeDelta|
+
+    (autoScroll and:[aBlock notNil]) ifFalse:[
+        ^ self stopAutoScroll
+    ].
+    autoScrollBlock notNil ifTrue:[
+        Processor removeTimedBlock:autoScrollBlock.
+    ] ifFalse:[
+        self compressMotionEvents:false.
+    ].
+
+    timeDelta := 0.5 / (aDistance abs).
+
+    autoScrollBlock := [
+        aBlock value.
+        Processor addTimedBlock:autoScrollBlock afterSeconds:timeDelta.
+    ].
+    Processor addTimedBlock:autoScrollBlock afterSeconds:timeDelta.
+
+
+!
+
+stopAutoScroll
+    "stop any autoScroll
+    "
+    autoScrollBlock notNil ifTrue:[
+        Processor removeTimedBlock:autoScrollBlock.
+        autoScrollBlock := nil.
+        self compressMotionEvents:true.
+    ].
+
+
 ! !
 
 !DSVColumnView methodsFor:'selection'!
@@ -3358,5 +3409,5 @@
 !DSVColumnView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.103 2000-02-23 14:28:38 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.104 2000-03-28 14:09:49 ca Exp $'
 ! !