OptionBox.st
changeset 95 7535cfca9509
parent 91 e8db16616e97
child 97 cbf495fe3b64
--- a/OptionBox.st	Wed Feb 22 04:41:31 1995 +0100
+++ b/OptionBox.st	Mon Feb 27 11:41:57 1995 +0100
@@ -21,7 +21,7 @@
 COPYRIGHT (c) 1991 by Claus Gittinger
 	     All Rights Reserved
 
-$Header: /cvs/stx/stx/libwidg/OptionBox.st,v 1.12 1995-02-22 01:21:14 claus Exp $
+$Header: /cvs/stx/stx/libwidg/OptionBox.st,v 1.13 1995-02-27 10:40:16 claus Exp $
 '!
 
 !OptionBox class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libwidg/OptionBox.st,v 1.12 1995-02-22 01:21:14 claus Exp $
+$Header: /cvs/stx/stx/libwidg/OptionBox.st,v 1.13 1995-02-27 10:40:16 claus Exp $
 "
 !
 
@@ -70,6 +70,30 @@
 "
 ! !
 
+!OptionBox class methodsFor:'easy startup '!
+
+request:title label:label form:aForm buttonLabels:labels values:values
+    "create a new optionBox, open it modal and return the value of
+     the corresponding values collection."
+
+    |box|
+
+    box := OptionBox title:title numberOfOptions:(labels size).
+    box buttonTitles:labels.
+    box action:[:n | ^ values at:n].
+    box label:label; form:aForm.
+    box showAtPointer.
+    ^ nil
+
+    "
+     OptionBox request:'select'
+	       label:'select any'
+	       form:(WarningBox iconBitmap)
+	       buttonLabels:#('one' 'two' 'three')
+	       values:#(1 2 3)
+    "
+! !
+
 !OptionBox class methodsFor:'instance creation'!
 
 title:titleString numberOfOptions:nOptions
@@ -160,6 +184,22 @@
     actions := actionBlocks
 !
 
+action:actionBlock
+    "define a single the action for all buttons.
+     The action will be evaluated with the button index as argument."
+
+    1 to:buttons size do:[:index |
+	|button|
+
+	button := buttons at:index.
+	button action:[
+		       (buttons at:index) turnOffWithoutRedraw.
+		       self hide.
+		       actionBlock value:index
+		      ]
+    ].
+!
+
 buttonTitles:titles actions:actionBlocks
     "define both button titles and actions"