DialogBox.st
changeset 6715 ffb69ee53ea0
parent 6700 47dc0c6fb70d
child 6729 53d2345cf12a
--- a/DialogBox.st	Wed Oct 16 16:12:37 2019 +0200
+++ b/DialogBox.st	Thu Oct 17 11:57:44 2019 +0200
@@ -6908,7 +6908,9 @@
 
             box := ex box.        
             heightBefore := box height.
+ 
             modifyBlock value:box.
+
             (box isKindOf:DialogBox) ifTrue:[
                 (vPanel := box verticalPanelIfPresent) notNil ifTrue:[
                     vPanel height:(vPanel preferredHeight).
@@ -6930,8 +6932,63 @@
         ].
     "
 
+    "
+     DialogBox 
+        modifyingBoxWith:[:box |
+            box allViewBackground:Color red.
+        ] do:[
+            Dialog information:'hello'.
+            Dialog information:'hello again (should be red)'.
+        ].
+    "
+
     "Modified (comment): / 15-05-2018 / 20:56:41 / stefan"
     "Modified: / 20-08-2018 / 11:46:31 / Claus Gittinger"
+    "Modified: / 16-10-2019 / 23:53:32 / Stefan Vogel"
+!
+
+withAdditionalActionButtonLabeled:label1 action:action1 do:boxOpeningBlock
+    "launch a Dialog. 
+     Add an additional action button to the bottom panel.
+     This will invoke the corresponding actions and keep the box open"
+
+    ^ self 
+        modifyingBoxWith:[:box |
+            |b wrappedAction|
+
+            wrappedAction := [
+                    "do it only for the first box and not for 
+                     follow-up boxes opened later."
+                    action1 on:self aboutToOpenBoxNotificationSignal do:[].
+                ].
+
+            (box isKindOf:DialogBox) ifTrue:[
+                b := Button label:label1 action:wrappedAction.
+                box addButton:b after:nil.
+                box forceResize.
+            ] ifFalse:[
+                b := Button label:label1 action:wrappedAction.
+                box application addButton:b.
+            ].    
+        ] 
+        do:boxOpeningBlock.
+
+    "
+     Dialog 
+        withAdditionalActionButtonLabeled:'Flash Transcript' 
+        action:[Transcript flash]
+        do:[ Dialog confirm:'some question' ].
+    "
+
+    "
+     Dialog 
+        withAdditionalActionButtonLabeled:'Oh,yes' 
+        action:[Dialog information:'This one without ''Oh yes''']
+        do:[ Dialog confirm:'some question' ].
+    "
+
+    "Created: / 16-10-2019 / 22:41:39 / Stefan Vogel"
+    "Modified: / 17-10-2019 / 00:01:55 / Stefan Vogel"
 !
 
 withAdditionalOKButtonLabeled:label1 action:action1 
@@ -6945,29 +7002,28 @@
             |b1 b2|
 
             (box isKindOf:DialogBox) ifTrue:[
-                b1 := Button label:label1 action:[action1 value. box okPressed].
+                b1 := Button label:label1 action:[action1 on:self aboutToOpenBoxNotificationSignal do:[]. box okPressed].
                 box addButton:b1 after:nil.
-                b2 := Button label:label2 action:[action2 value. box okPressed].
+                b2 := Button label:label2 action:[action2 on:self aboutToOpenBoxNotificationSignal do:[]. box okPressed].
                 box addButton:b2 after:nil.
                 box forceResize.
             ] ifFalse:[
-                b1 := Button label:label1 action:[action1 value. box application doAccept].
-                b2 := Button label:label2 action:[action2 value. box application doAccept].
+                b1 := Button label:label1 action:[action1 on:self aboutToOpenBoxNotificationSignal do:[]. box application doAccept].
+                b2 := Button label:label2 action:[action2 on:self aboutToOpenBoxNotificationSignal do:[]. box application doAccept].
                 box application addButton:b1; addButton:b2.
             ].    
         ] 
         do:boxOpeningBlock.
 
     "
-     |h|
-     h := true asValue.
      Dialog 
         withAdditionalOKButtonLabeled:'Oh,yes' action:[Transcript flash]
-        andOKButtonLabeled:'Oh,no' action:[Transcript flash]
+        andOKButtonLabeled:'Oh, yes too' action:[Transcript flash]
         do:[ Dialog confirm:'some question' ].
     "
 
     "Created: / 10-06-2019 / 14:29:32 / Claus Gittinger"
+    "Modified: / 17-10-2019 / 00:03:02 / Stefan Vogel"
 !
 
 withAdditionalOKButtonLabeled:label1 action:action1 do:boxOpeningBlock
@@ -6980,28 +7036,34 @@
             |b|
 
             (box isKindOf:DialogBox) ifTrue:[
-                b := Button label:label1 action:[action1 value. box okPressed].
+                b := Button label:label1 action:[action1 on:self aboutToOpenBoxNotificationSignal do:[]. box okPressed].
                 box addButton:b after:nil.
                 box forceResize.
             ] ifFalse:[
-                b := Button label:label1 action:[action1 value. box application doAccept].
+                b := Button label:label1 action:[action1 on:self aboutToOpenBoxNotificationSignal do:[]. box application doAccept].
                 box application addButton:b.
             ].    
         ] 
         do:boxOpeningBlock.
 
     "
-     |h|
-     h := true asValue.
      Dialog 
         withAdditionalOKButtonLabeled:'Oh,yes' 
         action:[Transcript flash]
         do:[ Dialog confirm:'some question' ].
     "
 
+    "
+     Dialog 
+        withAdditionalOKButtonLabeled:'Oh,yes' 
+        action:[Dialog information:'This one without ''Oh yes''']
+        do:[ Dialog confirm:'some question' ].
+    "
+
     "Created: / 01-07-2018 / 09:38:09 / Claus Gittinger"
     "Modified: / 13-09-2018 / 15:06:54 / Claus Gittinger"
     "Modified (comment): / 10-06-2019 / 14:30:35 / Claus Gittinger"
+    "Modified: / 17-10-2019 / 00:03:23 / Stefan Vogel"
 !
 
 withCheckBoxFor:checkModelOrNil labelled:checkLabel do:boxOpeningBlock