author | Claus Gittinger <cg@exept.de> |
Thu, 18 Jul 2002 11:25:02 +0200 | |
changeset 2555 | c2d277241837 |
parent 2542 | 53fc213c8815 |
child 2628 | 619483f17989 |
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 |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
328 |
try to complete the input. |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
329 |
Typically used with fileName-boxes." |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
330 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
331 |
enterField entryCompletionBlock:aBlock |
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 |
"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
|
334 |
! |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
335 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
336 |
trimBlanks:aBoolean |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
337 |
"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
|
338 |
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
|
339 |
setting trimBlanks to false disables this behavior. |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
340 |
(not normally useful in most applications)" |
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 |
trimBlanks := aBoolean |
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 |
"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
|
345 |
! ! |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
346 |
|
2227 | 347 |
!EnterBox methodsFor:'accessing-components'! |
669
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
348 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
349 |
enterField |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
350 |
"provide access to the entryfield" |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
351 |
|
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
352 |
^ enterField |
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 |
"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
|
355 |
! |
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 |
labelField |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
358 |
"provide access to the labelfield" |
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 |
^ 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 |
"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
|
363 |
! ! |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
364 |
|
2227 | 365 |
!EnterBox methodsFor:'accessing-contents'! |
77 | 366 |
|
367 |
contents |
|
368 |
"return my contents" |
|
369 |
||
370 |
^ enterField contents |
|
371 |
! |
|
372 |
||
144 | 373 |
contents:aString |
374 |
"set my contents" |
|
375 |
||
376 |
enterField contents:aString |
|
377 |
! |
|
378 |
||
77 | 379 |
initialText:aString |
380 |
"define the initial text in the enterfield. all will be selected initially" |
|
381 |
||
2444 | 382 |
self initialText:aString selected:true |
77 | 383 |
! |
384 |
||
197 | 385 |
initialText:aString selectFrom:start to:stop |
386 |
"define the initial text in the enterfield, and the part to be selected" |
|
387 |
||
2081 | 388 |
self initialText:aString. |
389 |
self selectFrom:start to:stop |
|
390 |
! |
|
391 |
||
2444 | 392 |
initialText:someString selected:selected |
393 |
"define the initial text in the enterfield; optionally, all is selected initially" |
|
394 |
||
395 |
enterField initialText:someString selected:selected |
|
396 |
! |
|
397 |
||
2081 | 398 |
selectFrom:start to:stop |
399 |
"define the initial selection in the enterfield" |
|
400 |
||
197 | 401 |
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
|
402 |
! ! |
197 | 403 |
|
2227 | 404 |
!EnterBox methodsFor:'accessing-look'! |
144 | 405 |
|
2020 | 406 |
noCancel |
407 |
"make the cancel button invisible - i.e. only the ok button is shown. |
|
408 |
Not useful here, but useful with display-only textBoxes." |
|
409 |
||
410 |
abortButton beInvisible. |
|
411 |
! |
|
412 |
||
77 | 413 |
title:aString |
414 |
"set the title to be displayed at top of enterBox" |
|
415 |
||
416 |
|oldSize| |
|
417 |
||
418 |
aString ~= labelField label ifTrue:[ |
|
419 |
oldSize := labelField extent. |
|
420 |
labelField label:aString. |
|
110 | 421 |
labelField forceResize. |
77 | 422 |
|
118 | 423 |
shown ifTrue:[ |
424 |
labelField extent ~= oldSize ifTrue:[ |
|
425 |
self resize |
|
426 |
] |
|
77 | 427 |
] |
428 |
] |
|
429 |
! |
|
430 |
||
431 |
title:titleString okText:okString |
|
432 |
"set title and text in okbutton" |
|
433 |
||
434 |
(titleString ~= labelField label or:[okString ~= okButton label]) ifTrue:[ |
|
435 |
okButton label:okString. |
|
436 |
okButton resize. |
|
437 |
labelField label:titleString. |
|
110 | 438 |
labelField forceResize. |
97 | 439 |
shown ifTrue:[self resize]. |
77 | 440 |
] |
441 |
! |
|
442 |
||
443 |
title:titleString okText:okString abortText:abortString |
|
444 |
"set title and texts in the buttons" |
|
445 |
||
446 |
(titleString ~= labelField label |
|
447 |
or:[okString ~= okButton label |
|
448 |
or:[abortString ~= abortButton label]]) ifTrue:[ |
|
449 |
okButton label:okString. |
|
450 |
okButton resize. |
|
451 |
abortButton label:abortString. |
|
452 |
abortButton resize. |
|
453 |
labelField label:titleString. |
|
110 | 454 |
labelField forceResize. |
97 | 455 |
shown ifTrue:[self resize]. |
77 | 456 |
] |
197 | 457 |
! ! |
181 | 458 |
|
197 | 459 |
!EnterBox methodsFor:'change & update'! |
181 | 460 |
|
197 | 461 |
update:something with:someArgument from:changedObject |
462 |
"sent if my enterbox thinks it needs more real-estate ..." |
|
181 | 463 |
|
197 | 464 |
changedObject == enterField ifTrue:[ |
465 |
something == #preferredExtent ifTrue:[ |
|
466 |
shown ifTrue:[self resizeUnderPointer]. |
|
467 |
^ self |
|
468 |
] |
|
469 |
]. |
|
470 |
super update:something with:someArgument from:changedObject |
|
0 | 471 |
! ! |
472 |
||
473 |
!EnterBox methodsFor:'initialization'! |
|
474 |
||
2555
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
475 |
addEnterField:aWidget |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
476 |
|space2 innerWidth| |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
477 |
|
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
478 |
enterField notNil ifTrue:[ |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
479 |
enterField removeDependent:self. |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
480 |
enterField destroy. |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
481 |
enterField := nil. |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
482 |
]. |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
483 |
|
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
484 |
space2 := 2 * ViewSpacing. |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
485 |
innerWidth := width - space2. |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
486 |
|
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
487 |
self addComponent:(enterField := aWidget). |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
488 |
enterField |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
489 |
origin:[0.0 @ (space2 + labelField preferredExtent y "height")] |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
490 |
extent:(1.0 @ enterField height). |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
491 |
enterField |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
492 |
leftInset:ViewSpacing-enterField borderWidth; |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
493 |
rightInset:ViewSpacing. |
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 |
enterField addDependent:self. "to get preferredExtent-changes" |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
496 |
|
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
497 |
self makeTabable:enterField |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
498 |
|
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
499 |
"Modified: 31.5.1996 / 21:51:28 / cg" |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
500 |
! |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
501 |
|
77 | 502 |
createEnterField |
503 |
"this has been extracted from the initialize method |
|
121 | 504 |
to allow redefinition in subclasses. (FilenameEnterBox for example). |
505 |
It shall return a new instance of the desired editField class." |
|
77 | 506 |
|
2555
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
507 |
|widget| |
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 |
widget := EditField new. |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
510 |
widget leaveAction:[:key | self okPressed]. |
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
511 |
^ widget |
77 | 512 |
! |
513 |
||
0 | 514 |
initialize |
90 | 515 |
|space2 innerWidth| |
0 | 516 |
|
517 |
super initialize. |
|
518 |
||
1763 | 519 |
self addAbortAndOkButtons. |
77 | 520 |
|
669
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
521 |
trimBlanks := true. |
150 | 522 |
label := resources string:'Enter'. |
73 | 523 |
|
0 | 524 |
space2 := 2 * ViewSpacing. |
73 | 525 |
innerWidth := width - space2. |
0 | 526 |
|
527 |
labelField := Label in:self. |
|
118 | 528 |
labelField |
669
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
529 |
label:''; |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
530 |
borderWidth:0; |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
531 |
adjust:#left; |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
532 |
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
|
533 |
leftInset:ViewSpacing; |
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
534 |
rightInset:ViewSpacing. |
0 | 535 |
|
2555
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
536 |
self addEnterField:(self createEnterField). |
0 | 537 |
! |
538 |
||
539 |
reAdjustGeometry |
|
540 |
"sent late in snapin processing - gives me a chance |
|
541 |
to resize for new font dimensions" |
|
542 |
||
543 |
super reAdjustGeometry. |
|
544 |
labelField resize. |
|
545 |
okButton resize. |
|
546 |
abortButton resize. |
|
547 |
self resize |
|
59 | 548 |
! ! |
549 |
||
62 | 550 |
!EnterBox methodsFor:'queries'! |
0 | 551 |
|
130 | 552 |
preferredExtent |
572 | 553 |
"compute the boxes preferredExtent from the components' sizes" |
554 |
||
110 | 555 |
|wWanted hWanted wPanel vs2 min |
556 |
labelPref enterPref panelPref| |
|
59 | 557 |
|
797 | 558 |
"/ If I have an explicit preferredExtent .. |
559 |
||
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
669
diff
changeset
|
560 |
preferredExtent notNil ifTrue:[ |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
669
diff
changeset
|
561 |
^ preferredExtent |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
669
diff
changeset
|
562 |
]. |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
669
diff
changeset
|
563 |
|
130 | 564 |
panelPref := buttonPanel preferredExtent. |
565 |
labelPref := labelField preferredExtent. |
|
566 |
enterPref := enterField preferredExtent. |
|
110 | 567 |
wWanted := (labelPref x max:enterPref x). |
568 |
wPanel := panelPref x. |
|
59 | 569 |
wPanel > wWanted ifTrue:[ |
572 | 570 |
wWanted := wPanel |
59 | 571 |
]. |
1615
7bb9ce880706
preferredExtent a bit smaller.
Claus Gittinger <cg@exept.de>
parents:
1613
diff
changeset
|
572 |
hWanted := labelPref y + ViewSpacing + enterPref y + |
7bb9ce880706
preferredExtent a bit smaller.
Claus Gittinger <cg@exept.de>
parents:
1613
diff
changeset
|
573 |
ViewSpacing + panelPref y + ViewSpacing. |
59 | 574 |
|
575 |
min := self class minExtent. |
|
576 |
wWanted < min x ifTrue:[ |
|
572 | 577 |
wWanted := min x |
59 | 578 |
]. |
579 |
hWanted < min y ifTrue:[ |
|
572 | 580 |
hWanted := min y |
59 | 581 |
]. |
110 | 582 |
vs2 := ViewSpacing * 2. |
572 | 583 |
^ (wWanted + vs2) @ (hWanted + vs2) |
584 |
||
1615
7bb9ce880706
preferredExtent a bit smaller.
Claus Gittinger <cg@exept.de>
parents:
1613
diff
changeset
|
585 |
"Modified: / 22.1.1998 / 09:57:55 / md" |
7bb9ce880706
preferredExtent a bit smaller.
Claus Gittinger <cg@exept.de>
parents:
1613
diff
changeset
|
586 |
"Modified: / 27.7.1998 / 20:18:41 / cg" |
0 | 587 |
! ! |
588 |
||
77 | 589 |
!EnterBox methodsFor:'startup'! |
590 |
||
591 |
request |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
592 |
"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
|
593 |
or an empty string, if abort was pressed" |
77 | 594 |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
595 |
^ self requestOnCancel:'' |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
596 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
597 |
"Modified: 27.1.1996 / 14:50:01 / cg" |
0 | 598 |
! |
599 |
||
77 | 600 |
request:title |
242 | 601 |
"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
|
602 |
or the empty string, if abort was pressed." |
0 | 603 |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
604 |
^ self request:title onCancel:'' |
242 | 605 |
|
606 |
" |
|
607 |
EnterBox request:'enter some string:' |
|
608 |
||
609 |
|bx| |
|
610 |
bx := EnterBox new. |
|
611 |
bx label:'foo bar baz'. |
|
612 |
bx request:'enter some string:' |
|
613 |
" |
|
614 |
||
615 |
"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
|
616 |
"Modified: 27.1.1996 / 14:49:23 / cg" |
181 | 617 |
! |
618 |
||
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
619 |
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
|
620 |
"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
|
621 |
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
|
622 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
623 |
self title:title. |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
624 |
^ self requestOnCancel:cancelValue |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
625 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
626 |
" |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
627 |
EnterBox request:'enter some string:' onCancel:nil |
181 | 628 |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
629 |
|bx| |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
630 |
bx := EnterBox new. |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
631 |
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
|
632 |
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
|
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 |
"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
|
636 |
"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
|
637 |
! |
181 | 638 |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
639 |
requestOnCancel:cancelValue |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
640 |
"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
|
641 |
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
|
642 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
643 |
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
|
644 |
self open. |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
645 |
^ cancelValue value |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
646 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
647 |
"Created: 27.1.1996 / 14:47:47 / cg" |
181 | 648 |
! |
649 |
||
650 |
requestPassword:title |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
651 |
"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
|
652 |
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
|
653 |
|
1879
25ac1b89ed31
change: return nil if cancel is pressed in #requestPassword.
Claus Gittinger <cg@exept.de>
parents:
1790
diff
changeset
|
654 |
^ 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
|
655 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
656 |
"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
|
657 |
"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
|
658 |
! |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
659 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
660 |
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
|
661 |
"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
|
662 |
or cancelValue, if abort was pressed" |
181 | 663 |
|
664 |
enterField passwordCharacter:$*. |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
665 |
^ self request:title onCancel:cancelValue |
181 | 666 |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
667 |
"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
|
668 |
"Created: 27.1.1996 / 14:52:13 / cg" |
77 | 669 |
! ! |
197 | 670 |
|
671 |
!EnterBox methodsFor:'user actions'! |
|
672 |
||
2542
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
673 |
actionArgument |
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
674 |
"fetch the entered string, trim spaces and return it" |
197 | 675 |
|
676 |
|string| |
|
677 |
||
2542
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
678 |
string := self contents. |
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
679 |
string isNil ifTrue:[ |
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
680 |
string := '' |
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
681 |
] ifFalse:[ |
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
682 |
trimBlanks ifTrue:[ |
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
683 |
string := string withoutSeparators |
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
684 |
] |
197 | 685 |
]. |
669
fef6f8160573
allow blank-trimming to be turned off
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
686 |
|
2542
53fc213c8815
refactored action evaluation
Claus Gittinger <cg@exept.de>
parents:
2447
diff
changeset
|
687 |
^ string |
197 | 688 |
! ! |
689 |
||
1613 | 690 |
!EnterBox class methodsFor:'documentation'! |
242 | 691 |
|
692 |
version |
|
2555
c2d277241837
refactored enterField creation
Claus Gittinger <cg@exept.de>
parents:
2542
diff
changeset
|
693 |
^ '$Header: /cvs/stx/stx/libwidg/EnterBox.st,v 1.57 2002-07-18 09:25:02 cg Exp $' |
242 | 694 |
! ! |