added postCreateCallBack option
authorClaus Gittinger <cg@exept.de>
Mon, 23 Apr 2001 10:21:56 +0200
changeset 2355 986d96f5ff6c
parent 2354 373ee1f525e3
child 2356 6416beb0f23a
added postCreateCallBack option
DialogBox.st
--- a/DialogBox.st	Sun Apr 22 13:34:23 2001 +0200
+++ b/DialogBox.st	Mon Apr 23 10:21:56 2001 +0200
@@ -1738,6 +1738,24 @@
      The matchPattern is set to pattern initially.
      Return the string, or nil if cancel was pressed."
 
+    ^ self
+        requestFileName:titleString 
+        default:defaultName 
+        ok:okText 
+        abort:abortText 
+        pattern:pattern 
+        fromDirectory:aDirectoryPathOrNil 
+        whenBoxCreatedEvaluate:nil
+!
+
+requestFileName:titleString default:defaultName ok:okText abort:abortText pattern:pattern fromDirectory:aDirectoryPathOrNil whenBoxCreatedEvaluate:boxCreatedCallback
+    "launch a Dialog, which allows user to enter a filename.
+     The files presented initially are those in aDirectoryPathOrNil, or the
+     last fileBox directory (default: current directory) (if a nil path is given).
+     The box will show okText in its okButton, abortText in the abortButton.
+     The matchPattern is set to pattern initially.
+     Return the string, or nil if cancel was pressed."
+
     |box defaultDir defaultNm dir enteredName|
 
     defaultNm := defaultName.
@@ -1770,6 +1788,7 @@
     ].
     box pattern:pattern.
     box initialText:defaultNm.
+    boxCreatedCallback notNil ifTrue:[boxCreatedCallback value:box].
     box showAtPointer.
     box action:nil.
     box destroy.
@@ -1961,6 +1980,28 @@
         #any (other)    - no validation
     "
 
+    ^ self
+        requestFileName:titleString 
+        default:defaultName 
+        version:versionSymbol 
+        ifFail:failBlock 
+        pattern:pattern 
+        fromDirectory:aDirectoryPath 
+        whenBoxCreatedEvaluate:nil
+!
+
+requestFileName:titleString default:defaultName version:versionSymbol ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPath whenBoxCreatedEvaluate:boxCreatedCallback
+    "launch a Dialog, which allows user to enter a filename.
+     Return the string or the value of failBlock if cancel was pressed.
+     The version argument allows validation of the files existance;
+     it may be any of:
+        #mustBeNew      - fail (return empty string) if the file exists
+        #new            - confirm if the file exists
+        #mustBeOld      - fail if the file does not exist
+        #old            - confirm if the file does not exist
+        #any (other)    - no validation
+    "
+
     |box defaultDir defaultNm|
 
     defaultNm := defaultName.
@@ -2007,6 +2048,7 @@
         box destroy. 
         ^ name
     ].
+    boxCreatedCallback notNil ifTrue:[boxCreatedCallback value:box].
     box showAtPointer.
     box action:nil.
     box destroy. 
@@ -6705,6 +6747,6 @@
 !DialogBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.161 2000-12-21 13:07:28 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.162 2001-04-23 08:21:56 cg Exp $'
 ! !
 DialogBox initialize!