DialogBox.st
changeset 1705 1a126505ac49
parent 1704 304ccbc56ec4
child 1707 c14a2460b698
--- a/DialogBox.st	Fri Oct 09 14:22:46 1998 +0200
+++ b/DialogBox.st	Fri Oct 09 16:14:40 1998 +0200
@@ -2112,34 +2112,63 @@
      the cancel-button is labelled cancelLabel (or the default, ifNil).
      Return the string or the value of cancelValue (if cancel was pressed)"
 
+    ^ self
+        request:aString 
+        displayAt:aPoint 
+        centered:centered 
+        action:resultAction 
+        initialAnswer:initial 
+        okLabel:okLabel 
+        cancelLabel:cancelLabel 
+        title:titleString 
+        onCancel:cancelValue 
+        list:nil
+
+!
+
+request:aString displayAt:aPoint centered:centered action:resultAction initialAnswer:initial okLabel:okLabel cancelLabel:cancelLabel title:titleString onCancel:cancelValue list:listToSelectFrom
+    "launch a Dialog, which allows user to enter a string.
+     The dialogs window is titled titleString, or the default (if nil).
+     If aPoint is nonNil, the box is shown there, optionally centered around it.
+     If it is nil, it is shown at the current pointer position or at the 
+     screen center (if centered is true).
+     The ok-button is labelled okLabel (or the default, ifNil),
+     the cancel-button is labelled cancelLabel (or the default, ifNil).
+     Return the string or the value of cancelValue (if cancel was pressed)"
+
     |box|
 
-    box := EnterBox title:aString.
+    listToSelectFrom isNil ifTrue:[
+        box := EnterBox title:aString.
+    ] ifFalse:[
+        box := EnterBoxWithList title:aString.
+        box list:listToSelectFrom.
+    ].
     box initialText:initial printString.
     box abortAction:[:val | box destroy. ^ cancelValue value].
     okLabel notNil ifTrue:[
-	box okText:okLabel.
+        box okText:okLabel.
     ].
     cancelLabel notNil ifTrue:[
-	box abortText:cancelLabel 
+        box abortText:cancelLabel 
     ].
     resultAction isNil ifTrue:[
-	box action:[:val | box destroy. ^ val]
+        box action:[:val | box destroy. ^ val]
     ] ifFalse:[
-	box action:[:val | box destroy. ^ resultAction value:val]
+        box action:[:val | box destroy. ^ resultAction value:val]
     ].
     titleString notNil ifTrue:[
-	box label:titleString
+        box label:titleString
     ].
 
     aPoint notNil ifTrue:[
-	box showAt:aPoint center:centered
+        box showAt:aPoint center:centered
     ] ifFalse:[
-	centered ifTrue:[
-	    box showAtCenter
-	] ifFalse:[
-	    box showAtPointer
-	]
+        centered ifTrue:[
+            box showAtCenter
+        ] ifFalse:[
+            box showAtPointer
+        ]
     ].
     box destroy. 
     ^ cancelValue value.
@@ -2147,42 +2176,42 @@
     "
      centered around 200@200:
 
-	 Dialog 
-	    request:'enter a string:'
-	    displayAt:200@200
-	    centered:true
-	    action:[:result | result printNewline]
-	    initialAnswer:'the default'
-	    okLabel:'yes'
-	    cancelLabel:'no'
-	    title:'foo'
-	    onCancel:#foo
+         Dialog 
+            request:'enter a string:'
+            displayAt:200@200
+            centered:true
+            action:[:result | result printNewline]
+            initialAnswer:'the default'
+            okLabel:'yes'
+            cancelLabel:'no'
+            title:'foo'
+            onCancel:#foo
 
      under mouse pointer:
 
-	 Dialog 
-	    request:'enter a string:'
-	    displayAt:nil
-	    centered:false 
-	    action:[:result | result printNewline]
-	    initialAnswer:'the default'
-	    okLabel:'yes'
-	    cancelLabel:'no'
-	    title:'foo'
-	    onCancel:#foo
+         Dialog 
+            request:'enter a string:'
+            displayAt:nil
+            centered:false 
+            action:[:result | result printNewline]
+            initialAnswer:'the default'
+            okLabel:'yes'
+            cancelLabel:'no'
+            title:'foo'
+            onCancel:#foo
 
      centered on the screen:
 
-	 Dialog 
-	    request:'enter a string:'
-	    displayAt:nil
-	    centered:true 
-	    action:[:result | result printNewline]
-	    initialAnswer:'the default'
-	    okLabel:'yes'
-	    cancelLabel:'no'
-	    title:'foo'
-	    onCancel:#foo
+         Dialog 
+            request:'enter a string:'
+            displayAt:nil
+            centered:true 
+            action:[:result | result printNewline]
+            initialAnswer:'the default'
+            okLabel:'yes'
+            cancelLabel:'no'
+            title:'foo'
+            onCancel:#foo
     "
 
     "Created: 29.5.1996 / 14:35:04 / cg"
@@ -2331,6 +2360,37 @@
     "Created: 29.5.1996 / 14:59:57 / cg"
 !
 
+request:aString initialAnswer:initial okLabel:okLabel title:titleString onCancel:cancelAction list:listOfChoices
+    "launch a Dialog, which allows user to enter something.
+     Return the entered string (may be empty string) 
+     or cancelValue (if cancel was pressed)"
+
+    ^ self 
+        request:aString 
+        displayAt:nil 
+        centered:false 
+        action:nil 
+        initialAnswer:initial
+        okLabel:okLabel
+        cancelLabel:nil
+        title:titleString
+        onCancel:cancelAction
+        list:listOfChoices
+
+    "
+     Dialog 
+         request:'enter a string:' 
+         initialAnswer:'the default'
+         okLabel:'ok'
+         title:'demo'
+         onCancel:nil
+         list:#('foo' 'bar' 'baz')
+    "
+
+    "Modified: 29.5.1996 / 14:28:24 / cg"
+    "Created: 29.5.1996 / 14:59:57 / cg"
+!
+
 request:aString initialAnswer:initial onCancel:cancelAction
     "launch a Dialog, which allows user to enter something.
      Return the entered string (may be empty string) 
@@ -2354,6 +2414,33 @@
     "Modified: 29.5.1996 / 14:28:24 / cg"
 !
 
+request:aString list:listOfChoices
+    "launch a Dialog, which allows user to enter something,
+     but adds a list of choices for fast input.
+     Return the entered string (may be empty string) 
+     or the empty string (if cancel was pressed)"
+
+    ^ self 
+        request:aString 
+        displayAt:nil 
+        centered:false 
+        action:nil 
+        initialAnswer:'' 
+        okLabel:nil 
+        cancelLabel:nil 
+        title:nil 
+        onCancel:nil 
+        list:listOfChoices
+
+    "
+     Dialog 
+         request:'enter a string:'
+         list:#('foo' 'bar' 'baz')
+    "
+
+    "Modified: 29.5.1996 / 14:26:25 / cg"
+!
+
 request:aString okLabel:okLabel
     "launch a Dialog, which allows user to enter something.
      The okButton is labelled as okLabel.
@@ -5705,6 +5792,6 @@
 !DialogBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.120 1998-10-09 12:22:46 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.121 1998-10-09 14:14:40 cg Exp $'
 ! !
 DialogBox initialize!