DialogBox.st
changeset 5836 05baebb0b524
parent 5811 e47e88107713
child 5837 9f78a5caa596
--- a/DialogBox.st	Wed Aug 31 18:47:22 2016 +0200
+++ b/DialogBox.st	Thu Sep 01 12:30:03 2016 +0200
@@ -1148,6 +1148,44 @@
         icon:aClass defaultIconForAboutBox
 !
 
+askWith:setupBlock ifNotNilOrEmptyDo:actionBlock
+    "utility: open a requestor with setupBlock;
+     if it answers ok, invoke actionBlock with the entered input.
+     Otherwise do nothing"
+     
+    |answer|
+
+    answer := setupBlock value.
+    answer notEmptyOrNil ifTrue:[
+        actionBlock value:answer
+    ].
+
+    "
+     Dialog 
+        askWith:[ Dialog requestFileName:'Some File:' ] 
+        ifNotNilOrEmptyDo:[:what | Transcript showCR:what ]
+    "
+!
+
+askYesNoWith:setupBlock ifYesDo:actionBlock
+    "utility: open a confirmer with setupBlock;
+     if it answers true, invoke actionBlock.
+     Otherwise do nothing"
+     
+    |answer|
+
+    answer := setupBlock value.
+    answer == true ifTrue:[
+        actionBlock value
+    ].
+
+    "
+     Dialog 
+        askYesNoWith:[ Dialog confirm:'Yes or No?' ] 
+        ifYesDo:[ Transcript showCR:'yes' ]
+    "
+!
+
 informUser:aString during:aBlock
     "show a message-box while executing aBlock"