#FEATURE by cg
class: DialogBox
class: DialogBox class
added:
#request:asPassWord:initialAnswer:and:asPassWord:initialAnswer:label:title:okLabel:cancelLabel:onCancel:
#request:asPassWord:on:and:asPassWord:on:label:title:okLabel:cancelLabel:onCancel:
--- a/DialogBox.st Tue Jul 16 15:06:25 2019 +0200
+++ b/DialogBox.st Tue Jul 16 16:14:15 2019 +0200
@@ -4039,6 +4039,97 @@
"Modified: 29.5.1996 / 14:26:25 / cg"
!
+request:string1 asPassWord:isPassword1 initialAnswer:initial1
+ and:string2 asPassWord:isPassword2 initialAnswer:initial2
+ label:label title:boxTitle
+ okLabel:okLabel cancelLabel:cancelLabel onCancel:cancelValue
+
+ "launch a Dialog, asking for 2 string values, labelled string1 and string2,
+ with corresponding initial values.
+ Above the fields, label is shown, and the window title will be boxTitle.
+ Returns the entered strings as a pair or the value from cancelValue.
+ Useful to ask for user+password or host+port"
+
+ |holder1 holder2|
+
+ holder1 := initial1 asValue.
+ holder2 := initial2 asValue.
+
+ ^ self
+ request:string1 asPassWord:isPassword1 on:holder1
+ and:string2 asPassWord:isPassword2 on:holder2
+ label:label title:boxTitle
+ okLabel:okLabel cancelLabel:cancelLabel onCancel:cancelValue
+
+ "
+ Dialog
+ request:'UserName:' asPassWord:false initialAnswer:'tim'
+ and:'Password' asPassWord:true initialAnswer:''
+ label:'Please Login'
+ title:'Login'
+ okLabel:'Login' cancelLabel:'Cancel'
+ onCancel:nil
+ "
+
+ "Created: / 16-07-2019 / 14:23:22 / Claus Gittinger"
+!
+
+request:string1 asPassWord:isPassword1 on:holder1
+ and:string2 asPassWord:isPassword2 on:holder2
+ label:label title:boxTitle
+ okLabel:okLabel cancelLabel:cancelLabel onCancel:cancelValue
+
+ "launch a Dialog, asking for 2 string values, labelled string1 and string2,
+ with corresponding initial values.
+ Above the fields, label is shown, and the window title will be boxTitle.
+ Returns the entered strings as a pair or the value from cancelValue.
+ Useful to ask for user+password or host+port"
+
+ |box in1 in2|
+
+ box := DialogBox new.
+ box windowTitle:boxTitle.
+
+ box addTextLabel:label.
+ in1 := box
+ addLabelledInputField:string1
+ adjust:#right
+ on:holder1
+ tabable:true
+ separateAtX:0.3.
+ isPassword1 ifTrue:[in1 bePassword].
+ in2 := box
+ addLabelledInputField:string2
+ adjust:#right
+ on:holder2
+ tabable:true
+ separateAtX:0.3.
+ isPassword2 ifTrue:[in2 bePassword].
+
+ box abortAction:[:val | box destroy. ^ cancelValue value].
+ box addAbortAndOkButtons.
+ okLabel notNil ifTrue:[ box okText:okLabel ].
+ cancelLabel notNil ifTrue:[ box abortText:cancelLabel ].
+
+ box open.
+ box accepted ifFalse:[
+ ^ cancelValue value.
+ ].
+ ^ { holder1 value . holder2 value }
+
+ "
+ Dialog
+ request:'UserName:' asPassWord:false initialAnswer:'tim'
+ and:'Password' asPassWord:true initialAnswer:''
+ label:'Please Login'
+ title:'Login'
+ okLabel:'Login' cancelLabel:'Cancel'
+ onCancel:nil
+ "
+
+ "Created: / 16-07-2019 / 15:09:36 / Claus Gittinger"
+!
+
request:aString displayAt:aPoint centered:centered action:resultAction initialAnswer:initial
"launch a Dialog, which allows user to enter a string.
If aPoint is nonNil, the box is shown there, optionally centered around