--- a/DialogBox.st Sat Jun 29 22:53:31 2019 +0200
+++ b/DialogBox.st Sun Jul 07 15:01:35 2019 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 1994 by Claus Gittinger
All Rights Reserved
@@ -5052,6 +5050,37 @@
"Created: / 18-08-2011 / 19:28:13 / cg"
!
+request:aString list:listOfChoices initialAnswer:initialAnswer initialSelection:initialSelection
+ "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:(ForceModalBoxesToOpenAtCenter ? false)
+ action:nil
+ initialAnswer:initialAnswer
+ okLabel:nil
+ cancelLabel:nil
+ title:nil
+ onCancel:nil
+ list:listOfChoices
+ initialSelection:initialSelection
+ entryCompletionBlock:nil
+
+ "
+ Dialog
+ request:'Enter a string:'
+ list:#('foo' 'bar' 'baz')
+ initialAnswer:'foe'
+ "
+
+ "Modified: / 29-05-1996 / 14:26:25 / cg"
+ "Created: / 18-08-2011 / 19:28:13 / cg"
+!
+
request:aString okLabel:okLabel
"launch a Dialog, which allows user to enter something.
The okButton is labelled as okLabel.
@@ -6591,23 +6620,25 @@
This allows modifyBlock to add additional controls to the dialog.
ModifyBlock is called with the box as argument."
- ^ openingBlock on:self aboutToOpenBoxNotificationSignal do:[:ex |
- |box heightBefore heightAfter vPanel|
-
- box := ex box.
- heightBefore := box height.
- modifyBlock value:box.
- (box isKindOf:DialogBox) ifTrue:[
- (vPanel := box verticalPanelIfPresent) notNil ifTrue:[
- vPanel height:(vPanel preferredHeight).
- box forceResize.
+ ^ openingBlock
+ on:self aboutToOpenBoxNotificationSignal
+ do:[:ex |
+ |box heightBefore heightAfter vPanel|
+
+ box := ex box.
+ heightBefore := box height.
+ modifyBlock value:box.
+ (box isKindOf:DialogBox) ifTrue:[
+ (vPanel := box verticalPanelIfPresent) notNil ifTrue:[
+ vPanel height:(vPanel preferredHeight).
+ box forceResize.
+ ].
].
- ].
- heightAfter := box height.
- heightAfter ~= heightBefore ifTrue:[
- box makeFullyVisible.
+ heightAfter := box height.
+ heightAfter ~= heightBefore ifTrue:[
+ box makeFullyVisible.
+ ].
].
- ].
"
DialogBox
@@ -6692,13 +6723,18 @@
"Modified (comment): / 10-06-2019 / 14:30:35 / Claus Gittinger"
!
-withCheckBoxFor:checkModel labelled:checkLabel do:boxOpeningBlock
+withCheckBoxFor:checkModelOrNil labelled:checkLabel do:boxOpeningBlock
"launch a Dialog to warn or request something.
- Add a checkbox on a value holder."
-
- self
+ If checkModelOrNil is not nil,
+ then add a checkbox on a value holder."
+
+ checkModelOrNil isNil ifTrue:[
+ ^ boxOpeningBlock value
+ ].
+
+ ^ self
modifyingBoxWith:[:box |
- box verticalPanel add:((CheckBox label:checkLabel) model:checkModel).
+ box verticalPanel add:((CheckBox label:checkLabel) model:checkModelOrNil).
]
do:boxOpeningBlock.
@@ -6714,20 +6750,27 @@
"Created: / 10-09-2017 / 12:26:07 / cg"
!
-withOptoutHolder:aValueHolder labelled:labelString do:boxOpeningBlock
+withOptoutHolder:aValueHolderOrNil labelled:labelString do:boxOpeningBlock
"launch a Dialog to warn user.
- Add a 'do not show this dialog again'-like checkbox,
+ If aValueHolderOrNil is not nil,
+ then add a 'do not show this dialog again'-like checkbox,
and change aValueHolder if the checkbox was checked."
- self
- modifyingBoxWith:[:box |
- box verticalPanel add:((CheckBox label:labelString) model:aValueHolder).
- ]
- do:boxOpeningBlock.
-
- "
- Dialog
- withOptoutOption:[Transcript flash]
+ ^ self withCheckBoxFor:aValueHolderOrNil labelled:labelString do:boxOpeningBlock
+
+ "
+ |holder|
+ holder := false asValue.
+ Dialog
+ withOptoutHolder:holder
+ labelled:'opt out'
+ do:[ Dialog confirm:'some question' ].
+ Transcript showCR:(holder value)
+ "
+
+ "
+ Dialog
+ withOptoutHolder:nil
labelled:'opt out'
do:[ Dialog confirm:'some question' ].
"
@@ -6735,29 +6778,37 @@
"Modified: / 22-11-2016 / 04:20:38 / cg"
!
-withOptoutOption:optOutAction1 labelled:labelString1
- andOptoutOption:optOutAction2 labelled:labelString2
+withOptoutOption:optOutAction1OrNil labelled:labelString1
+ andOptoutOption:optOutAction2OrNil labelled:labelString2
do:boxOpeningBlock
"launch a Dialog to warn user.
- Add two 'do not show this dialog again'-like checkboxes,
+ If the corresponding optOutActionXOrNil is notNil,
+ add a 'do not show this dialog again'-like checkbox,
and call optOutActionX after the dialog, if the checkbox was indeed checked."
|optOutHolder1 optOutHolder2|
+ (optOutAction1OrNil isNil and:[optOutAction2OrNil isNil]) ifTrue:[
+ ^ boxOpeningBlock value
+ ].
+
optOutHolder1 := false asValue.
optOutHolder2 := false asValue.
- [
+ ^ [
self
modifyingBoxWith:[:box |
- box verticalPanel
- add:((CheckBox label:labelString1) model:optOutHolder1);
- add:((CheckBox label:labelString2) model:optOutHolder2).
+ optOutAction1OrNil notNil ifTrue:[
+ box verticalPanel add:((CheckBox label:labelString1) model:optOutHolder1)
+ ].
+ optOutAction2OrNil notNil ifTrue:[
+ box verticalPanel add:((CheckBox label:labelString2) model:optOutHolder2).
+ ]
]
do:boxOpeningBlock
] ensure:[
- optOutHolder1 value ifTrue:[ optOutAction1 value ].
- optOutHolder2 value ifTrue:[ optOutAction2 value ].
+ optOutHolder1 value ifTrue:[ optOutAction1OrNil value ].
+ optOutHolder2 value ifTrue:[ optOutAction2OrNil value ].
].
"
@@ -6771,22 +6822,27 @@
"Modified: / 22-11-2016 / 04:21:10 / cg"
!
-withOptoutOption:optOutAction labelled:labelString do:boxOpeningBlock
- "launch a Dialog to warn user.
- Add a 'do not show this dialog again'-like checkbox,
+withOptoutOption:optOutActionOrNil labelled:labelString do:boxOpeningBlock
+ "launch a Dialog to warn user.
+ If optOutActionOrNil is not nil,
+ then add a 'do not show this dialog again'-like checkbox,
and call optOutAction after the dialog, if the checkbox was indeed checked."
|holder|
+ optOutActionOrNil isNil ifTrue:[
+ ^ boxOpeningBlock value
+ ].
+
holder := false asValue.
- [
+ ^ [
self
modifyingBoxWith:[:box |
box verticalPanel add:((CheckBox label:labelString) model:holder).
]
do:boxOpeningBlock.
] ensure:[
- holder value ifTrue:[optOutAction value]
+ holder value ifTrue:[optOutActionOrNil value]
]
"
@@ -6795,17 +6851,24 @@
labelled:'opt out'
do:[ Dialog confirm:'some question' ].
"
+ "
+ Dialog
+ withOptoutOption:nil
+ labelled:'opt out'
+ do:[ Dialog confirm:'some question' ].
+ "
"Modified: / 22-11-2016 / 04:20:38 / cg"
!
-withOptoutOption:optOutAction labelled:labelString warn:warnString
+withOptoutOption:optOutActionOrNil labelled:labelString warn:warnString
"launch a Dialog to warn user.
- Add a 'do not show this dialog again'-like checkbox,
+ If optOutActionOrNil is not nil,
+ then add a 'do not show this dialog again'-like checkbox,
and call optOutAction after the warning, if the checkbox was indeed checked."
- self
- withOptoutOption:optOutAction
+ ^ self
+ withOptoutOption:optOutActionOrNil
labelled:labelString
do:[self warn:warnString]