author | convert-repo |
Mon, 20 Jan 2020 04:27:28 +0000 | |
changeset 6803 | ee24f1bc43ae |
parent 6637 | ffe4d10bc89d |
child 6814 | e9155e18dfb4 |
permissions | -rw-r--r-- |
6409 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
" |
5 | 4 |
COPYRIGHT (c) 1990 by Claus Gittinger |
59 | 5 |
All Rights Reserved |
0 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
2227 | 14 |
"{ Package: 'stx:libwidg' }" |
15 |
||
5285 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
77 | 18 |
DialogBox subclass:#EnterBox |
669
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
19 |
instanceVariableNames:'labelField enterField trimBlanks' |
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
20 |
classVariableNames:'' |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
21 |
poolDictionaries:'' |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
22 |
category:'Views-DialogBoxes' |
0 | 23 |
! |
24 |
||
1613 | 25 |
!EnterBox class methodsFor:'documentation'! |
3 | 26 |
|
38 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 1990 by Claus Gittinger |
|
59 | 30 |
All Rights Reserved |
38 | 31 |
|
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
3 | 41 |
documentation |
42 |
" |
|
355 | 43 |
Historic note: |
44 |
originally, ST/X had separate classes for the various entry methods; |
|
45 |
there were YesNoBox, EnterBox, InfoBox and so on. |
|
46 |
In the meantime, the DialogBox class (and therefore its alias: Dialog) |
|
5896 | 47 |
is going to duplicate most functionality found in these classes. |
355 | 48 |
|
49 |
In the future, those existing subclasses' functionality is going to |
|
50 |
be moved fully into Dialog, and the subclasses will be replaced by dummy |
|
51 |
delegators. (They will be kept for backward compatibility, though). |
|
52 |
||
53 |
||
5286 | 54 |
This class implements a pop-up box to enter some string |
38 | 55 |
with 2 buttons; a cancel button, and a trigger-action button. |
242 | 56 |
Normally, the box is created and opened with the single message: |
57 |
EnterBox request:'someString' |
|
58 |
which returns nil if aborted and the entered string otherwise. |
|
3 | 59 |
|
242 | 60 |
However, to control more details of the box, it may also be created first |
5286 | 61 |
(EnterBox new) and then modified as appropriate before it is shown. |
242 | 62 |
|
5896 | 63 |
For example, the boxes title can be changed with: |
242 | 64 |
|
65 |
aBox title:'some string' |
|
38 | 66 |
|
5896 | 67 |
The two button-labels default to 'abort' and 'ok'; |
38 | 68 |
they can be changed using: |
3 | 69 |
|
242 | 70 |
aBox okText:'someString' |
71 |
aBox abortText:'someString' |
|
38 | 72 |
|
73 |
The initial text in the enterfield can be set using: |
|
3 | 74 |
|
242 | 75 |
aBox initialText:'someString' |
3 | 76 |
|
38 | 77 |
when the ok-button is pressed, an action is performed, which is |
78 |
set using: |
|
3 | 79 |
|
242 | 80 |
aBox action:[ ... ] |
3 | 81 |
|
38 | 82 |
the abort-action defaults to no-action, but can also be set. |
242 | 83 |
|
38 | 84 |
The box can be opened modal (i.e. the currently active view will |
85 |
be suspended) or modeless. The default is modal (i.e. sending #open |
|
86 |
is equivalent to #openModal). |
|
242 | 87 |
|
88 |
Most of the above is also available via messages to Dialog for ST-80 compatibility |
|
5286 | 89 |
(i.e. ""Dialog request:someString"" is the same as ""EnterBox request:'someString'"") |
585 | 90 |
|
91 |
[author:] |
|
92 |
Claus Gittinger |
|
93 |
||
94 |
[see also:] |
|
95 |
DialogBox |
|
593 | 96 |
EnterBox2 YesNoBox ListSelectionBox FileSelectionBox FileSaveBox |
97 |
EditField EditTextView |
|
98 |
EnterFieldGroup |
|
62 | 99 |
" |
100 |
! |
|
3 | 101 |
|
5896 | 102 |
examples |
62 | 103 |
" |
242 | 104 |
examples (for ST-80 compatibility, please use Dialog messages): |
105 |
||
106 |
simple (most common): |
|
593 | 107 |
[exBegin] |
242 | 108 |
|someString| |
109 |
||
110 |
someString := EnterBox request:'enter a string'. |
|
655 | 111 |
Transcript showCR:someString |
593 | 112 |
[exEnd] |
113 |
||
59 | 114 |
|
242 | 115 |
creating first, setting actions and manually opening: |
593 | 116 |
[exBegin] |
242 | 117 |
|box| |
118 |
||
119 |
box := EnterBox new. |
|
120 |
box title:'your name please:'. |
|
669
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
121 |
box action:[:arg | Transcript showCR:'entered: ''' , arg printString , '''']. |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
122 |
box open |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
123 |
[exEnd] |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
124 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
125 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
126 |
turning off trimming of leading/trailing spaces (seldom required): |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
127 |
[exBegin] |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
128 |
|box| |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
129 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
130 |
box := EnterBox new. |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
131 |
box title:'your name please:'. |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
132 |
box action:[:arg | Transcript showCR:'entered: ''' , arg printString , '''']. |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
133 |
box trimBlanks:false. |
242 | 134 |
box open |
593 | 135 |
[exEnd] |
59 | 136 |
|
242 | 137 |
|
593 | 138 |
non-modal |
139 |
(just for the demo; it does not really make sense, |
|
140 |
since cancel-button has no effect): |
|
141 |
[exBegin] |
|
242 | 142 |
|box| |
8 | 143 |
|
242 | 144 |
box := EnterBox new. |
145 |
box title:'your name please:'. |
|
655 | 146 |
box action:[:arg | Transcript showCR:'entered: ' , arg printString]. |
242 | 147 |
box openModeless |
593 | 148 |
[exEnd] |
149 |
||
59 | 150 |
|
242 | 151 |
for easier instance creation, there are also some combination methods: |
593 | 152 |
[exBegin] |
242 | 153 |
|box| |
62 | 154 |
|
5896 | 155 |
box := EnterBox |
242 | 156 |
title:'your name please:' |
655 | 157 |
action:[:arg | Transcript showCR:'entered: ' , arg printString]. |
593 | 158 |
box open |
159 |
[exEnd] |
|
160 |
||
62 | 161 |
|
59 | 162 |
If the box is needed to ask for a simple string, you can also use the |
163 |
#request method, to bring up a box, let it ask for something and return |
|
164 |
the entered string. This method will return nil, if the box was |
|
165 |
closed with the 'abort' button. |
|
166 |
Example: |
|
593 | 167 |
[exBegin] |
242 | 168 |
|box string| |
59 | 169 |
|
242 | 170 |
box := EnterBox request:'input some string:'. |
171 |
string isNil ifTrue:[ |
|
655 | 172 |
Transcript showCR:'no input' |
242 | 173 |
] ifFalse:[ |
655 | 174 |
Transcript showCR:('the entered string was: ' , string) |
242 | 175 |
] |
593 | 176 |
[exEnd] |
177 |
||
38 | 178 |
|
59 | 179 |
of course, this can be written shorter as: |
593 | 180 |
[exBegin] |
242 | 181 |
|string| |
59 | 182 |
|
242 | 183 |
string := EnterBox request:'input some string:'. |
184 |
string isNil ifTrue:[ |
|
655 | 185 |
Transcript showCR:'no input' |
242 | 186 |
] ifFalse:[ |
655 | 187 |
Transcript showCR:('the entered string was: ' , string) |
242 | 188 |
] |
593 | 189 |
[exEnd] |
181 | 190 |
|
191 |
||
192 |
A box for passwords is created with: |
|
593 | 193 |
[exBegin] |
242 | 194 |
|box| |
181 | 195 |
|
5896 | 196 |
box := EnterBox |
242 | 197 |
title:'your name please:' |
655 | 198 |
action:[:arg | Transcript showCR:'entered: ' , arg printString]. |
242 | 199 |
box enterField passwordCharacter:$*. |
200 |
box showAtPointer |
|
593 | 201 |
[exEnd] |
202 |
||
181 | 203 |
|
204 |
or simply: |
|
593 | 205 |
[exBegin] |
242 | 206 |
|string| |
181 | 207 |
|
242 | 208 |
string := EnterBox requestPassword:'enter your password:'. |
655 | 209 |
Transcript showCR:string. |
593 | 210 |
[exEnd] |
211 |
||
212 |
ATTENTION: |
|
5896 | 213 |
for ST-80 compatibility, please use protocol from Dialog |
593 | 214 |
(which is an alias for DialogBox): |
215 |
[exBegin] |
|
216 |
|string| |
|
217 |
||
218 |
string := Dialog request:'input some string:'. |
|
219 |
string isNil ifTrue:[ |
|
655 | 220 |
Transcript showCR:'no input' |
593 | 221 |
] ifFalse:[ |
655 | 222 |
Transcript showCR:('the entered string was: ' , string) |
593 | 223 |
] |
224 |
[exEnd] |
|
5896 | 225 |
and: |
593 | 226 |
[exBegin] |
227 |
|string| |
|
228 |
||
229 |
string := Dialog requestPassword:'enter your password:'. |
|
655 | 230 |
Transcript showCR:string. |
593 | 231 |
[exEnd] |
3 | 232 |
" |
181 | 233 |
|
234 |
"Modified: 16.11.1995 / 21:28:11 / cg" |
|
3 | 235 |
! ! |
236 |
||
1613 | 237 |
!EnterBox class methodsFor:'instance creation'! |
0 | 238 |
|
239 |
action:aBlock |
|
5896 | 240 |
"create and return a new EnterBox |
5285 | 241 |
which will evaluate aBlock when 'ok' is pressed. |
5896 | 242 |
Obsolete (but kept for backward compatibility): |
5285 | 243 |
boxes are never used without a proper label" |
0 | 244 |
|
245 |
^ (self new) action:aBlock |
|
246 |
||
5285 | 247 |
" |
248 |
(EnterBox action:[:string | Transcript showCR:string]) showAtPointer |
|
249 |
(EnterBox action:[:string | Transcript showCR:string]) open |
|
250 |
(EnterBox action:[:string | Transcript showCR:string]) open |
|
251 |
" |
|
0 | 252 |
! |
253 |
||
62 | 254 |
title:titleString |
255 |
"create and return a new EnterBox with title aString" |
|
256 |
||
257 |
^ self new title:titleString |
|
258 |
! |
|
259 |
||
101 | 260 |
title:titleString action:aBlock |
261 |
"create and return a new EnterBox with title aString, |
|
262 |
which will evaluate aBlock when 'ok' is pressed" |
|
263 |
||
264 |
^ (self title:titleString) action:aBlock |
|
265 |
! |
|
266 |
||
197 | 267 |
title:titleString okText:okText abortText:abortText action:aBlock |
268 |
"create and return a new EnterBox with title aString, and buttons showing |
|
269 |
okText and abortText; it will evaluate aBlock when 'ok' is pressed" |
|
270 |
||
5896 | 271 |
^ (self title:titleString okText:okText action:aBlock) abortText:abortText |
197 | 272 |
! |
273 |
||
101 | 274 |
title:titleString okText:okText action:aBlock |
275 |
"create and return a new EnterBox with title aString, and ok button showing |
|
276 |
okText; it will evaluate aBlock when 'ok' is pressed" |
|
277 |
||
278 |
^ (self title:titleString action:aBlock) okText:okText |
|
77 | 279 |
! ! |
280 |
||
1613 | 281 |
!EnterBox class methodsFor:'defaults'! |
77 | 282 |
|
197 | 283 |
defaultExtent |
571 | 284 |
"return the default extent of my instances. |
285 |
The value returned here is usually ignored, and |
|
286 |
the value from preferredExtent taken instead." |
|
287 |
||
1613 | 288 |
^ (Screen current pixelPerMillimeter * (60 @ 20)) rounded |
571 | 289 |
|
1613 | 290 |
"Modified: / 22.1.1998 / 09:57:26 / md" |
291 |
"Modified: / 27.7.1998 / 20:15:52 / cg" |
|
197 | 292 |
! |
293 |
||
77 | 294 |
minExtent |
295 |
^ self defaultExtent |
|
296 |
! ! |
|
297 |
||
2447 | 298 |
!EnterBox class methodsFor:'easy startup'! |
77 | 299 |
|
300 |
request:aTitle |
|
301 |
"create and show an enterBox asking for aTitle. |
|
5607 | 302 |
Return the entered string or an empty string (if abort was pressed). |
77 | 303 |
The string may be empty, in case return was pressed immediately." |
304 |
||
305 |
^ self new request:aTitle |
|
306 |
||
307 |
" |
|
5286 | 308 |
EnterBox request:'Enter a string:' |
77 | 309 |
" |
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
310 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
311 |
"Modified: 27.1.1996 / 14:34:23 / cg" |
181 | 312 |
! |
313 |
||
314 |
requestPassword:aTitle |
|
315 |
"create and show an enterBox asking for aTitle. |
|
316 |
The box is setup to NOT display entered characters (as with password entry). |
|
317 |
Return the entered string or nil (if abort was pressed). |
|
318 |
The string may be empty, in case return was pressed immediately." |
|
319 |
||
320 |
^ self new requestPassword:aTitle |
|
321 |
||
322 |
" |
|
323 |
|s| |
|
324 |
||
5286 | 325 |
s := EnterBox requestPassword:'Enter a password string:'. |
326 |
Transcript showCR:'you entered: ' , s asString |
|
181 | 327 |
" |
328 |
||
329 |
"Created: 16.11.1995 / 21:25:08 / cg" |
|
77 | 330 |
! ! |
331 |
||
2227 | 332 |
!EnterBox methodsFor:'accessing-behavior'! |
669
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
333 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
334 |
entryCompletionBlock:aBlock |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
335 |
"define an entryCompletion block; if nonNil, that one |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
336 |
is evaluated if TAB is pressed in the field and should |
2628 | 337 |
try to complete the input. |
338 |
The block gets the current contents and the field itself as optional arguments |
|
339 |
(i.e. it can be a 0, 1 or 2-arg block). |
|
669
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
340 |
Typically used with fileName-boxes." |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
341 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
342 |
enterField entryCompletionBlock:aBlock |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
343 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
344 |
"Modified: 22.5.1996 / 15:19:31 / cg" |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
345 |
! |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
346 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
347 |
trimBlanks:aBoolean |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
348 |
"set/clear blank trimming in the returned string. |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
349 |
By default, leading and trailing spaces are removed from the input; |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
350 |
setting trimBlanks to false disables this behavior. |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
351 |
(not normally useful in most applications)" |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
352 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
353 |
trimBlanks := aBoolean |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
354 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
355 |
"Created: 22.5.1996 / 15:23:45 / cg" |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
356 |
! ! |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
357 |
|
2227 | 358 |
!EnterBox methodsFor:'accessing-components'! |
669
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
359 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
360 |
enterField |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
361 |
"provide access to the entryfield" |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
362 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
363 |
^ enterField |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
364 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
365 |
"Created: 16.11.1995 / 21:23:48 / cg" |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
366 |
! |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
367 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
368 |
labelField |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
369 |
"provide access to the labelfield" |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
370 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
371 |
^ labelField |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
372 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
373 |
"Created: 16.11.1995 / 21:23:48 / cg" |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
374 |
! ! |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
375 |
|
2227 | 376 |
!EnterBox methodsFor:'accessing-contents'! |
77 | 377 |
|
378 |
contents |
|
379 |
"return my contents" |
|
380 |
||
381 |
^ enterField contents |
|
382 |
! |
|
383 |
||
144 | 384 |
contents:aString |
385 |
"set my contents" |
|
386 |
||
387 |
enterField contents:aString |
|
388 |
! |
|
389 |
||
2728
9a63179c0d0f
+initialAnswer: for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
2628
diff
changeset
|
390 |
initialAnswer:aString |
9a63179c0d0f
+initialAnswer: for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
2628
diff
changeset
|
391 |
"for protocol compatibility - an alias for initialText:" |
9a63179c0d0f
+initialAnswer: for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
2628
diff
changeset
|
392 |
|
9a63179c0d0f
+initialAnswer: for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
2628
diff
changeset
|
393 |
self initialText:aString |
9a63179c0d0f
+initialAnswer: for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
2628
diff
changeset
|
394 |
! |
9a63179c0d0f
+initialAnswer: for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
2628
diff
changeset
|
395 |
|
77 | 396 |
initialText:aString |
397 |
"define the initial text in the enterfield. all will be selected initially" |
|
398 |
||
2444 | 399 |
self initialText:aString selected:true |
77 | 400 |
! |
401 |
||
197 | 402 |
initialText:aString selectFrom:start to:stop |
403 |
"define the initial text in the enterfield, and the part to be selected" |
|
404 |
||
2081 | 405 |
self initialText:aString. |
4557 | 406 |
self selectFromCharacterPosition:start to:stop |
2081 | 407 |
! |
408 |
||
2444 | 409 |
initialText:someString selected:selected |
410 |
"define the initial text in the enterfield; optionally, all is selected initially" |
|
411 |
||
412 |
enterField initialText:someString selected:selected |
|
413 |
! |
|
414 |
||
2081 | 415 |
selectFrom:start to:stop |
416 |
"define the initial selection in the enterfield" |
|
417 |
||
197 | 418 |
enterField selectFromLine:1 col:start toLine:1 col:stop |
4559 | 419 |
! |
420 |
||
421 |
selectFromCharacterPosition:start to:stop |
|
422 |
"define the initial selection in the enterfield" |
|
423 |
||
424 |
enterField selectFromCharacterPosition:start to:stop |
|
669
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
425 |
! ! |
197 | 426 |
|
2227 | 427 |
!EnterBox methodsFor:'accessing-look'! |
144 | 428 |
|
2020 | 429 |
noCancel |
430 |
"make the cancel button invisible - i.e. only the ok button is shown. |
|
431 |
Not useful here, but useful with display-only textBoxes." |
|
432 |
||
433 |
abortButton beInvisible. |
|
434 |
! |
|
435 |
||
77 | 436 |
title:aString |
6630 | 437 |
"set the title to be displayed at top of the enterBox. |
438 |
This is NOT the window title." |
|
77 | 439 |
|
440 |
|oldSize| |
|
441 |
||
442 |
aString ~= labelField label ifTrue:[ |
|
3329 | 443 |
oldSize := labelField extent. |
444 |
labelField label:aString. |
|
445 |
labelField forceResize. |
|
77 | 446 |
|
3329 | 447 |
shown ifTrue:[ |
448 |
labelField extent ~= oldSize ifTrue:[ |
|
449 |
self resize |
|
450 |
] |
|
451 |
] ifFalse:[ |
|
452 |
self sizeChanged:nil. |
|
453 |
] |
|
77 | 454 |
] |
6409 | 455 |
|
6630 | 456 |
"Modified (comment): / 15-07-2019 / 16:34:02 / Claus Gittinger" |
77 | 457 |
! |
458 |
||
459 |
title:titleString okText:okString |
|
6630 | 460 |
"set title and text in okbutton. |
461 |
This title is NOT the window title." |
|
77 | 462 |
|
463 |
(titleString ~= labelField label or:[okString ~= okButton label]) ifTrue:[ |
|
3329 | 464 |
okButton label:okString. |
465 |
okButton resize. |
|
466 |
labelField label:titleString. |
|
467 |
labelField forceResize. |
|
5896 | 468 |
shown |
3329 | 469 |
ifTrue:[self resize] |
470 |
ifFalse:[ self sizeChanged:nil]. |
|
77 | 471 |
] |
6630 | 472 |
|
473 |
"Modified (comment): / 15-07-2019 / 16:34:12 / Claus Gittinger" |
|
77 | 474 |
! |
475 |
||
476 |
title:titleString okText:okString abortText:abortString |
|
6630 | 477 |
"set title and texts in the buttons. |
478 |
This title is NOT the window title." |
|
77 | 479 |
|
5896 | 480 |
(titleString ~= labelField label |
77 | 481 |
or:[okString ~= okButton label |
482 |
or:[abortString ~= abortButton label]]) ifTrue:[ |
|
3329 | 483 |
okButton label:okString. |
484 |
okButton resize. |
|
485 |
abortButton label:abortString. |
|
486 |
abortButton resize. |
|
487 |
labelField label:titleString. |
|
488 |
labelField forceResize. |
|
5896 | 489 |
shown |
3329 | 490 |
ifTrue:[self resize] |
491 |
ifFalse:[ self sizeChanged:nil]. |
|
77 | 492 |
] |
6630 | 493 |
|
494 |
"Modified (comment): / 15-07-2019 / 16:34:17 / Claus Gittinger" |
|
197 | 495 |
! ! |
181 | 496 |
|
197 | 497 |
!EnterBox methodsFor:'change & update'! |
181 | 498 |
|
197 | 499 |
update:something with:someArgument from:changedObject |
500 |
"sent if my enterbox thinks it needs more real-estate ..." |
|
181 | 501 |
|
197 | 502 |
changedObject == enterField ifTrue:[ |
503 |
something == #preferredExtent ifTrue:[ |
|
504 |
shown ifTrue:[self resizeUnderPointer]. |
|
505 |
^ self |
|
506 |
] |
|
507 |
]. |
|
508 |
super update:something with:someArgument from:changedObject |
|
0 | 509 |
! ! |
510 |
||
511 |
!EnterBox methodsFor:'initialization'! |
|
512 |
||
2555
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
513 |
addEnterField:aWidget |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
514 |
|space2 innerWidth| |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
515 |
|
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
516 |
enterField notNil ifTrue:[ |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
517 |
enterField removeDependent:self. |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
518 |
enterField destroy. |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
519 |
enterField := nil. |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
520 |
]. |
5286 | 521 |
enterField := aWidget. |
2555
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
522 |
|
3937 | 523 |
space2 := 2 * ViewSpacing. |
524 |
innerWidth := width - space2. |
|
2555
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
525 |
|
5286 | 526 |
self addComponent:aWidget. |
5896 | 527 |
enterField |
4087 | 528 |
width:1.0; |
529 |
origin:[0.0 @ (space2 + labelField preferredHeight "height")]; |
|
6637 | 530 |
leftInset:(ViewSpacing-aWidget borderWidth) rightInset:1 "ViewSpacing". |
2555
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
531 |
|
5286 | 532 |
aWidget addDependent:self. "to get preferredExtent-changes" |
2555
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
533 |
|
5286 | 534 |
self makeTabable:aWidget |
2555
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
535 |
|
4358 | 536 |
"Modified: / 23-01-2012 / 17:30:17 / cg" |
6637 | 537 |
"Modified (format): / 16-07-2019 / 16:37:23 / Claus Gittinger" |
2555
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
538 |
! |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
539 |
|
77 | 540 |
createEnterField |
541 |
"this has been extracted from the initialize method |
|
121 | 542 |
to allow redefinition in subclasses. (FilenameEnterBox for example). |
543 |
It shall return a new instance of the desired editField class." |
|
77 | 544 |
|
2555
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
545 |
|widget| |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
546 |
|
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
547 |
widget := EditField new. |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
548 |
widget leaveAction:[:key | self okPressed]. |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
549 |
^ widget |
77 | 550 |
! |
551 |
||
0 | 552 |
initialize |
90 | 553 |
|space2 innerWidth| |
0 | 554 |
|
555 |
super initialize. |
|
556 |
||
1763 | 557 |
self addAbortAndOkButtons. |
77 | 558 |
|
669
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
559 |
trimBlanks := true. |
5286 | 560 |
label := resources string:'Enter'. "/ bad name: this is the window label |
73 | 561 |
|
0 | 562 |
space2 := 2 * ViewSpacing. |
73 | 563 |
innerWidth := width - space2. |
0 | 564 |
|
3937 | 565 |
labelField := Label in:self. |
5896 | 566 |
labelField |
567 |
label:''; |
|
669
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
568 |
borderWidth:0; |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
569 |
adjust:#left; |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
570 |
origin:(0.0 @ ViewSpacing) extent:[1.0 @ labelField height]; |
6637 | 571 |
leftInset:ViewSpacing rightInset:ViewSpacing. |
0 | 572 |
|
2555
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
573 |
self addEnterField:(self createEnterField). |
3943
253c9ebed9fe
yPosition fixes when adding components in the aboutToOpen hook.
Claus Gittinger <cg@exept.de>
parents:
3937
diff
changeset
|
574 |
yPosition := enterField bottom + ViewSpacing. |
6637 | 575 |
|
576 |
"Modified: / 16-07-2019 / 16:37:27 / Claus Gittinger" |
|
0 | 577 |
! |
578 |
||
579 |
reAdjustGeometry |
|
5286 | 580 |
"sent late in the setup process - gives me a chance |
0 | 581 |
to resize for new font dimensions" |
582 |
||
583 |
super reAdjustGeometry. |
|
584 |
labelField resize. |
|
585 |
okButton resize. |
|
586 |
abortButton resize. |
|
6220 | 587 |
|
0 | 588 |
self resize |
6220 | 589 |
|
590 |
"Modified (format): / 22-10-2017 / 01:20:18 / cg" |
|
59 | 591 |
! ! |
592 |
||
62 | 593 |
!EnterBox methodsFor:'queries'! |
0 | 594 |
|
6505 | 595 |
computePreferredExtent |
572 | 596 |
"compute the boxes preferredExtent from the components' sizes" |
597 |
||
6141 | 598 |
|wWanted hWanted vs2 min |
6220 | 599 |
labelPref enterPref bPanelPref vPanelPref| |
59 | 600 |
|
6220 | 601 |
bPanelPref := buttonPanel preferredExtent. |
5324 | 602 |
labelPref := labelField preferredExtent. |
603 |
enterPref := enterField preferredExtent. |
|
6220 | 604 |
wWanted := (labelPref x max:enterPref x) max:bPanelPref x. |
6141 | 605 |
|
5324 | 606 |
hWanted := labelPref y + ViewSpacing + enterPref y + |
6220 | 607 |
ViewSpacing + bPanelPref y + ViewSpacing. |
608 |
||
5324 | 609 |
verticalPanel notNil ifTrue:[ |
6220 | 610 |
vPanelPref := verticalPanel preferredExtent. |
611 |
hWanted := hWanted + ViewSpacing + (vPanelPref y). |
|
612 |
wWanted := wWanted max:vPanelPref x. |
|
5324 | 613 |
]. |
614 |
||
6141 | 615 |
vs2 := ViewSpacing * 2. |
5324 | 616 |
min := self class minExtent. |
6141 | 617 |
wWanted := (wWanted max: min x) + vs2. |
618 |
hWanted := (hWanted max: min y) + vs2. |
|
572 | 619 |
|
6141 | 620 |
^ wWanted @ hWanted |
621 |
||
6505 | 622 |
"Created: / 09-11-2018 / 19:51:57 / Claus Gittinger" |
0 | 623 |
! ! |
624 |
||
77 | 625 |
!EnterBox methodsFor:'startup'! |
626 |
||
627 |
request |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
628 |
"open the box and return the entered string |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
629 |
or an empty string, if abort was pressed" |
77 | 630 |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
631 |
^ self requestOnCancel:'' |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
632 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
633 |
"Modified: 27.1.1996 / 14:50:01 / cg" |
0 | 634 |
! |
635 |
||
77 | 636 |
request:title |
242 | 637 |
"set the title, open the box and return the entered string, |
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
638 |
or the empty string, if abort was pressed." |
0 | 639 |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
640 |
^ self request:title onCancel:'' |
242 | 641 |
|
642 |
" |
|
5896 | 643 |
EnterBox request:'enter some string:' |
242 | 644 |
|
645 |
|bx| |
|
646 |
bx := EnterBox new. |
|
647 |
bx label:'foo bar baz'. |
|
5896 | 648 |
bx request:'enter some string:' |
242 | 649 |
" |
650 |
||
651 |
"Created: 7.12.1995 / 23:12:19 / cg" |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
652 |
"Modified: 27.1.1996 / 14:49:23 / cg" |
181 | 653 |
! |
654 |
||
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
655 |
request:title onCancel:cancelValue |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
656 |
"set the title, open the box and return the entered string, |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
657 |
or cancelValue if abort was pressed." |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
658 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
659 |
self title:title. |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
660 |
^ self requestOnCancel:cancelValue |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
661 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
662 |
" |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
663 |
EnterBox request:'enter some string:' onCancel:nil |
181 | 664 |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
665 |
|bx| |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
666 |
bx := EnterBox new. |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
667 |
bx label:'foo bar baz'. |
5896 | 668 |
bx request:'enter some string:' onCancel:#foo |
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
669 |
" |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
670 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
671 |
"Created: 7.12.1995 / 23:12:19 / cg" |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
672 |
"Modified: 27.1.1996 / 14:48:39 / cg" |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
673 |
! |
181 | 674 |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
675 |
requestOnCancel:cancelValue |
5896 | 676 |
"open the box and return the entered string |
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
677 |
or cancelValue, if abort was pressed" |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
678 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
679 |
self action:[:string | ^ string]. |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
680 |
self open. |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
681 |
^ cancelValue value |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
682 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
683 |
"Created: 27.1.1996 / 14:47:47 / cg" |
181 | 684 |
! |
685 |
||
686 |
requestPassword:title |
|
5896 | 687 |
"set the title, set password mode, open the box and return the entered string |
1879
25ac1b89ed31
change: return nil if cancel is pressed in #requestPassword.
Claus Gittinger <cg@exept.de>
parents:
1790
diff
changeset
|
688 |
or nil, if abort was pressed" |
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
689 |
|
1879
25ac1b89ed31
change: return nil if cancel is pressed in #requestPassword.
Claus Gittinger <cg@exept.de>
parents:
1790
diff
changeset
|
690 |
^ self requestPassword:title onCancel:nil |
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
691 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
692 |
"Created: 16.11.1995 / 21:25:33 / cg" |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
693 |
"Modified: 27.1.1996 / 14:52:36 / cg" |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
694 |
! |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
695 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
696 |
requestPassword:title onCancel:cancelValue |
5896 | 697 |
"set the title, set password mode, open the box and return the entered string |
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
698 |
or cancelValue, if abort was pressed" |
181 | 699 |
|
3586 | 700 |
enterField bePassword. |
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
701 |
^ self request:title onCancel:cancelValue |
181 | 702 |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
703 |
"Modified: 27.1.1996 / 14:34:07 / cg" |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
704 |
"Created: 27.1.1996 / 14:52:13 / cg" |
77 | 705 |
! ! |
197 | 706 |
|
707 |
!EnterBox methodsFor:'user actions'! |
|
708 |
||
2542
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
709 |
actionArgument |
5286 | 710 |
"fetch the entered string, optionally trim spaces and return it" |
197 | 711 |
|
712 |
|string| |
|
713 |
||
2542
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
714 |
string := self contents. |
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
715 |
string isNil ifTrue:[ |
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
716 |
string := '' |
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
717 |
] ifFalse:[ |
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
718 |
trimBlanks ifTrue:[ |
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
719 |
string := string withoutSeparators |
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
720 |
] |
197 | 721 |
]. |
669
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
722 |
|
2542
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
723 |
^ string |
197 | 724 |
! ! |
725 |
||
1613 | 726 |
!EnterBox class methodsFor:'documentation'! |
242 | 727 |
|
728 |
version |
|
5607 | 729 |
^ '$Header$' |
4087 | 730 |
! |
731 |
||
732 |
version_CVS |
|
5607 | 733 |
^ '$Header$' |
242 | 734 |
! ! |
4557 | 735 |