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