useIndex:
authorca
Wed, 04 Jun 1997 13:23:34 +0200
changeset 1235 23748485375c
parent 1234 9c7d9fb08c3f
child 1236 529f36ae3217
useIndex: change changeMsg & aspectMsg dependant on state
SelListV.st
SelectionInListView.st
--- a/SelListV.st	Wed Jun 04 13:22:12 1997 +0200
+++ b/SelListV.st	Wed Jun 04 13:23:34 1997 +0200
@@ -1096,7 +1096,21 @@
      If clear, the value(s) (i.e. the selected string) is passed.
      Default is true."
 
-    useIndex := aBoolean
+    useIndex ~~ aBoolean ifTrue:[
+        useIndex := aBoolean.
+        useIndex ifTrue:[
+            changeMsg == #selection: ifTrue:[
+                changeMsg := #selectionIndex:.
+                aspectMsg := #selectionIndex.
+            ]
+        ] ifFalse:[
+            changeMsg == #selectionIndex: ifTrue:[
+                changeMsg := #selection:.
+                aspectMsg := #selection.
+            ]
+        ].
+    ].
+
 ! !
 
 !SelectionInListView methodsFor:'accessing-attributes'!
@@ -1625,23 +1639,23 @@
 
 update:something with:aParameter from:changedObject
     changedObject == model ifTrue:[
-	something == aspectMsg ifTrue:[
-	    self getListFromModel.
-	    self getSelectionFromModel.
-	    ^ self
-	].
-	something == listMsg ifTrue:[
-	    self getListFromModel.
-	    ^ self
-	].
-	something == initialSelectionMsg ifTrue:[
-	    self getSelectionFromModel.
-	    ^ self
-	].
-	something == #empty ifTrue:[
-	    self list:nil.
-	    ^ self
-	].
+        something == aspectMsg ifTrue:[
+            self getListFromModel.
+            self getSelectionFromModel.
+            ^ self
+        ].
+        something == listMsg ifTrue:[
+            self getListFromModel.
+            ^ self
+        ].
+        something == initialSelectionMsg ifTrue:[
+            self getSelectionFromModel.
+            ^ self
+        ].
+        something == #empty ifTrue:[
+            self list:nil.
+            ^ self
+        ].
     ].
     ^ super update:something with:aParameter from:changedObject
 ! !
@@ -2452,7 +2466,7 @@
     model notNil ifTrue:[
         initialSelectionMsg notNil ifTrue:[
             sel := model perform:initialSelectionMsg.
-            useIndex ifTrue:[
+            (useIndex or:[sel isNumber]) ifTrue:[
                 self setSelection:sel 
             ] ifFalse:[
                 self setSelectElement:sel.
@@ -3284,5 +3298,5 @@
 !SelectionInListView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Attic/SelListV.st,v 1.105 1997-05-06 07:32:17 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Attic/SelListV.st,v 1.106 1997-06-04 11:23:34 ca Exp $'
 ! !
--- a/SelectionInListView.st	Wed Jun 04 13:22:12 1997 +0200
+++ b/SelectionInListView.st	Wed Jun 04 13:23:34 1997 +0200
@@ -1096,7 +1096,21 @@
      If clear, the value(s) (i.e. the selected string) is passed.
      Default is true."
 
-    useIndex := aBoolean
+    useIndex ~~ aBoolean ifTrue:[
+        useIndex := aBoolean.
+        useIndex ifTrue:[
+            changeMsg == #selection: ifTrue:[
+                changeMsg := #selectionIndex:.
+                aspectMsg := #selectionIndex.
+            ]
+        ] ifFalse:[
+            changeMsg == #selectionIndex: ifTrue:[
+                changeMsg := #selection:.
+                aspectMsg := #selection.
+            ]
+        ].
+    ].
+
 ! !
 
 !SelectionInListView methodsFor:'accessing-attributes'!
@@ -1625,23 +1639,23 @@
 
 update:something with:aParameter from:changedObject
     changedObject == model ifTrue:[
-	something == aspectMsg ifTrue:[
-	    self getListFromModel.
-	    self getSelectionFromModel.
-	    ^ self
-	].
-	something == listMsg ifTrue:[
-	    self getListFromModel.
-	    ^ self
-	].
-	something == initialSelectionMsg ifTrue:[
-	    self getSelectionFromModel.
-	    ^ self
-	].
-	something == #empty ifTrue:[
-	    self list:nil.
-	    ^ self
-	].
+        something == aspectMsg ifTrue:[
+            self getListFromModel.
+            self getSelectionFromModel.
+            ^ self
+        ].
+        something == listMsg ifTrue:[
+            self getListFromModel.
+            ^ self
+        ].
+        something == initialSelectionMsg ifTrue:[
+            self getSelectionFromModel.
+            ^ self
+        ].
+        something == #empty ifTrue:[
+            self list:nil.
+            ^ self
+        ].
     ].
     ^ super update:something with:aParameter from:changedObject
 ! !
@@ -2452,7 +2466,7 @@
     model notNil ifTrue:[
         initialSelectionMsg notNil ifTrue:[
             sel := model perform:initialSelectionMsg.
-            useIndex ifTrue:[
+            (useIndex or:[sel isNumber]) ifTrue:[
                 self setSelection:sel 
             ] ifFalse:[
                 self setSelectElement:sel.
@@ -3284,5 +3298,5 @@
 !SelectionInListView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.105 1997-05-06 07:32:17 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.106 1997-06-04 11:23:34 ca Exp $'
 ! !