Merge jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Fri, 02 Sep 2016 17:42:50 +0100
branchjv
changeset 5840 7b658477a2a1
parent 5839 2cdb82875bf2 (current diff)
parent 5837 9f78a5caa596 (diff)
child 5844 4ebd8fb3feda
Merge
--- a/DialogBox.st	Wed Aug 31 22:52:14 2016 +0100
+++ b/DialogBox.st	Fri Sep 02 17:42:50 2016 +0100
@@ -1148,6 +1148,49 @@
         icon:aClass defaultIconForAboutBox
 !
 
+ask: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 
+        ask:[ Dialog request:'Some Answer:' ] 
+        ifNotNilOrEmptyDo:[:what | Transcript showCR:what ]
+    "
+    "
+     Dialog 
+        ask:[ Dialog requestFileName:'Some File:' ] 
+        ifNotNilOrEmptyDo:[:what | Transcript showCR:what ]
+    "
+!
+
+askYesNo: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 
+        askYesNo:[ Dialog confirm:'Yes or No?' ] 
+        ifYesDo:[ Transcript showCR:'yes' ]
+    "
+!
+
 informUser:aString during:aBlock
     "show a message-box while executing aBlock"
 
--- a/MenuView.st	Wed Aug 31 22:52:14 2016 +0100
+++ b/MenuView.st	Fri Sep 02 17:42:50 2016 +0100
@@ -2327,18 +2327,21 @@
                                 theReceiver := receiver.
                             ].
 
-                            theSelector isArray ifTrue:[
-                                theReceiver perform:(theSelector first) withArguments:(theSelector copyFrom:2)
-                            ] ifFalse:[
-                                theSelector numArgs == 0 ifTrue:[
-                                    theReceiver perform:theSelector
+                            theSelector isBlock ifTrue:[
+                                theSelector value 
+                            ] ifFalse:[    
+                                theSelector isArray ifTrue:[
+                                    theReceiver perform:(theSelector first) withArguments:(theSelector copyFrom:2)
                                 ] ifFalse:[
-                                    isCheck ifTrue:[
-                                        self redrawLine:idx.
-                                        val := checkOn.
-                                    ].
-                                
-                                    theReceiver perform:theSelector with:val 
+                                    theSelector numArgs == 0 ifTrue:[
+                                        theReceiver perform:theSelector
+                                    ] ifFalse:[
+                                        isCheck ifTrue:[
+                                            self redrawLine:idx.
+                                            val := checkOn.
+                                        ].
+                                        theReceiver perform:theSelector with:val 
+                                    ]
                                 ]
                             ]
                         ]