#REFACTORING by cg
class: TextBox
added: #openOn:title:windowTitle:readOnly:
class: TextBox class
changed: #openOn:title:windowTitle:readOnly:
--- a/TextBox.st Tue Jun 25 03:26:50 2019 +0000
+++ b/TextBox.st Wed Jun 26 10:56:41 2019 +0200
@@ -150,28 +150,8 @@
above the text areay. The optional windowTitle is used as title in the caption.
return (the possibly modified) text if accepted; nil otherwise."
- |box returnValue usedWindowTitle|
-
- box := self new.
- readOnly ifTrue:[ box textViewClass:TextView ].
- box initialize.
- titleString notNil ifTrue:[ box title:titleString ].
- box initialText:someText.
- box action:[:text | returnValue := text].
- box readOnly:readOnly.
- readOnly ifTrue:[ box abortButton destroy ].
-
- usedWindowTitle := windowTitle.
- usedWindowTitle isNil ifTrue:[
- titleString notNil ifTrue:[
- usedWindowTitle := titleString asString asStringCollection first
- ] ifFalse:[
- usedWindowTitle := readOnly ifTrue:'Value' ifFalse:'Input'
- ].
- ].
- box window label:usedWindowTitle.
- box showAtPointer.
- ^ returnValue.
+ ^ self new
+ openOn:someText title:titleString windowTitle:windowTitle readOnly:readOnly
"
TextBox openOn:'hello' title:'hi there' windowTitle:'some Box' readOnly:true
@@ -183,6 +163,7 @@
"
"Created: / 29-10-2010 / 17:10:04 / cg"
+ "Modified: / 26-06-2019 / 10:55:57 / Claus Gittinger"
! !
!TextBox class methodsFor:'defaults'!
@@ -266,6 +247,45 @@
"TextBox new showAtPointer"
"Modified: / 29-10-2010 / 17:14:49 / cg"
+!
+
+openOn:someText title:titleString windowTitle:windowTitle readOnly:readOnly
+ "open a textBox on some text, the optional titleString is shown as label
+ above the text areay. The optional windowTitle is used as title in the caption.
+ return (the possibly modified) text if accepted; nil otherwise."
+
+ |returnValue usedWindowTitle|
+
+ readOnly ifTrue:[ self textViewClass:TextView ].
+ self initialize.
+ titleString notNil ifTrue:[ self title:titleString ].
+ self initialText:someText.
+ self action:[:text | returnValue := text].
+ self readOnly:readOnly.
+ readOnly ifTrue:[ self abortButton destroy ].
+
+ usedWindowTitle := windowTitle.
+ usedWindowTitle isNil ifTrue:[
+ titleString notNil ifTrue:[
+ usedWindowTitle := titleString asString asStringCollection first
+ ] ifFalse:[
+ usedWindowTitle := readOnly ifTrue:'Value' ifFalse:'Input'
+ ].
+ ].
+ self window label:usedWindowTitle.
+ self showAtPointer.
+ ^ returnValue.
+
+ "
+ TextBox openOn:'hello' title:'hi there' windowTitle:'some Box' readOnly:true
+ TextBox openOn:'hello' title:'hi there' windowTitle:'some Box' readOnly:false
+ TextBox openOn:'hello' title:'hi there' windowTitle:nil readOnly:false
+ TextBox openOn:'hello' title:nil windowTitle:'some Box' readOnly:false
+ TextBox openOn:'hello' title:nil windowTitle:nil readOnly:false
+ TextBox openOn:'hello' title:nil windowTitle:'foo' readOnly:false
+ "
+
+ "Created: / 26-06-2019 / 10:55:37 / Claus Gittinger"
! !
!TextBox methodsFor:'queries'!