SelectionInListView.st
changeset 1163 05ec30ba9b17
parent 1157 33ed50527a8a
child 1181 ad5004cb2969
--- a/SelectionInListView.st	Fri Mar 28 20:56:30 1997 +0100
+++ b/SelectionInListView.st	Fri Mar 28 21:28:29 1997 +0100
@@ -18,7 +18,7 @@
 		ignoreReselect arrowLevel smallArrow keyActionStyle
 		returnKeyActionStyle toggleSelect strikeOut iSearchString items
 		doubleClickMsg hilightStyle allowDrag endDragAction dragIsActive
-		clickPosition'
+		clickPosition enableChannel'
 	classVariableNames:'RightArrowShadowForm RightArrowLightForm RightArrowForm
 		SmallRightArrowShadowForm SmallRightArrowLightForm
 		DefaultForegroundColor DefaultBackgroundColor
@@ -381,6 +381,49 @@
         top open
                                                                         [exEnd]
 
+      enable / disable:
+                                                                        [exBegin]
+        |top slv|
+
+        top := StandardSystemView new
+                label:'select';
+                minExtent:100@100;
+                maxExtent:300@400;
+                extent:200@200.
+
+        slv := SelectionInListView new.
+        slv list:(Filename currentDirectory directoryContents).
+        slv action:[:index | Transcript showCR:'selected ' , index printString].
+        slv disable.
+        top add:(ScrollableView forView:slv) in:(0.0@0.0 corner:1.0@1.0).
+        top open.
+        Delay waitForSeconds:5. 
+        slv enable.
+                                                                        [exEnd]
+
+      enable / disable via a channel:
+                                                                        [exBegin]
+        |top slv enableChannel t|
+
+        enableChannel := true asValue.
+        t := Toggle label:'enable'.
+        t model:enableChannel.
+        t open.
+
+        top := StandardSystemView new
+                label:'select';
+                minExtent:100@100;
+                maxExtent:300@400;
+                extent:200@200.
+
+        slv := SelectionInListView new.
+        slv list:(Filename currentDirectory directoryContents).
+        slv action:[:index | Transcript showCR:'selected ' , index printString].
+        slv enableChannel:enableChannel.
+        top add:(ScrollableView forView:slv) in:(0.0@0.0 corner:1.0@1.0).
+        top open.
+                                                                        [exEnd]
+
     using a Model:
                                                                         [exBegin]
         |top slv model|
@@ -1274,6 +1317,35 @@
     toggleSelect := aBoolean.
 ! !
 
+!SelectionInListView methodsFor:'accessing-channels'!
+
+enableChannel
+    ^ enableChannel
+
+    "Created: 28.3.1997 / 21:24:00 / cg"
+!
+
+enableChannel:aValueHolder 
+    "set the valueHolder, which holds the enable boolean value"
+
+    |wasEnabled|
+
+    enableChannel notNil ifTrue:[
+        wasEnabled := enableChannel value.
+        enableChannel retractInterestsFor:self. 
+    ] ifFalse:[
+        wasEnabled := enabled
+    ].
+    enableChannel := aValueHolder.
+    aValueHolder onChangeSend:#enableStateChange to:self.
+    enableChannel value ~~ wasEnabled ifTrue:[
+        self enableStateChange
+    ]
+
+    "Modified: 30.4.1996 / 15:10:03 / cg"
+    "Created: 28.3.1997 / 21:24:37 / cg"
+! !
+
 !SelectionInListView methodsFor:'accessing-contents'!
 
 add:aValue beforeIndex:index
@@ -1892,6 +1964,16 @@
     "Modified: 14.2.1997 / 16:48:53 / cg"
 !
 
+enableStateChange
+    enableChannel value ifTrue:[
+        self enable
+    ] ifFalse:[
+        self disable
+    ].
+
+    "Created: 28.3.1997 / 21:25:01 / cg"
+!
+
 key:key select:index x:x y:y
     "select an entry by a keyboard action.
      This is treated like a doubleClick on that entry"
@@ -3144,5 +3226,5 @@
 !SelectionInListView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.96 1997-03-27 10:26:18 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.97 1997-03-28 20:28:29 cg Exp $'
 ! !