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