added #useIndex:
authorClaus Gittinger <cg@exept.de>
Tue, 09 Jul 2002 13:57:55 +0200
changeset 2541 dca07e5245d3
parent 2540 56b92c7a787c
child 2542 53fc213c8815
added #useIndex:
ListSelectionBox.st
--- a/ListSelectionBox.st	Fri Jul 05 15:40:02 2002 +0200
+++ b/ListSelectionBox.st	Tue Jul 09 13:57:55 2002 +0200
@@ -63,6 +63,18 @@
         box showAtPointer
                                                                         [exEnd]
 
+    with index (instead of list-entry) and without an enterField:
+                                                                        [exBegin]
+        |box|
+
+        box := ListSelectionBox new.
+        box title:'select something:'.
+        box list:#('foo' 'bar' 'baz').
+        box useIndex:true.
+        box okAction:[:sel | Transcript show:'the selection was:' ; showCR:sel].
+        box showAtPointer
+                                                                        [exEnd]
+
 
     with a default:
                                                                         [exBegin]
@@ -118,6 +130,16 @@
     newBox := super title:titleString okText:okText abortText:abortText
 		    action:aBlock.
     ^ newBox list:aList
+!
+
+title:titleString okText:okText abortText:abortText list:aList useIndex:useIndex action:aBlock
+    "create and return a new listSelectionBox with list already defined"
+
+    |newBox|
+
+    newBox := self title:titleString okText:okText abortText:abortText action:aBlock.
+    newBox useIndex:useIndex.
+    ^ newBox list:aList
 ! !
 
 !ListSelectionBox class methodsFor:'defaults'!
@@ -179,6 +201,13 @@
     ^ selectionList selection
 
     "Created: 14.10.1996 / 16:28:50 / cg"
+!
+
+useIndex:aBoolean
+    aBoolean ifTrue:[
+        self noEnterField
+    ].
+    ^ selectionList useIndex:aBoolean
 ! !
 
 !ListSelectionBox methodsFor:'accessing-components'!
@@ -358,6 +387,13 @@
 
 !ListSelectionBox methodsFor:'user actions'!
 
+actionArgument
+    selectionList useIndex ifTrue:[
+        ^self selectionIndex.
+    ].
+    ^ super actionArgument
+!
+
 doubleClick
     "doubleClick on an entry is select & ok"
 
@@ -385,5 +421,5 @@
 !ListSelectionBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/ListSelectionBox.st,v 1.48 2002-02-06 09:33:35 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/ListSelectionBox.st,v 1.49 2002-07-09 11:57:55 cg Exp $'
 ! !