author | ca |
Fri, 09 Feb 1996 13:48:15 +0100 | |
changeset 338 | 9cbc51998a23 |
parent 306 | 6a6a1513b713 |
child 355 | a55f62047156 |
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 |
||
77 | 13 |
DialogBox subclass:#EnterBox |
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
14 |
instanceVariableNames:'labelField enterField' |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
15 |
classVariableNames:'' |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
16 |
poolDictionaries:'' |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
17 |
category:'Views-DialogBoxes' |
0 | 18 |
! |
19 |
||
3 | 20 |
!EnterBox class methodsFor:'documentation'! |
21 |
||
38 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1990 by Claus Gittinger |
|
59 | 25 |
All Rights Reserved |
38 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
3 | 36 |
documentation |
37 |
" |
|
38 | 38 |
this class implements a pop-up box to enter some string |
39 |
with 2 buttons; a cancel button, and a trigger-action button. |
|
242 | 40 |
Normally, the box is created and opened with the single message: |
41 |
EnterBox request:'someString' |
|
42 |
which returns nil if aborted and the entered string otherwise. |
|
3 | 43 |
|
242 | 44 |
However, to control more details of the box, it may also be created first |
45 |
(EnterBox new) and then modified as appropriate before its shown. |
|
46 |
||
47 |
For example, the boxes title can be changed with: |
|
48 |
||
49 |
aBox title:'some string' |
|
38 | 50 |
|
51 |
The two button-labels default to 'abort' and 'ok'; |
|
52 |
they can be changed using: |
|
3 | 53 |
|
242 | 54 |
aBox okText:'someString' |
55 |
aBox abortText:'someString' |
|
38 | 56 |
|
57 |
The initial text in the enterfield can be set using: |
|
3 | 58 |
|
242 | 59 |
aBox initialText:'someString' |
3 | 60 |
|
38 | 61 |
when the ok-button is pressed, an action is performed, which is |
62 |
set using: |
|
3 | 63 |
|
242 | 64 |
aBox action:[ ... ] |
3 | 65 |
|
38 | 66 |
the abort-action defaults to no-action, but can also be set. |
242 | 67 |
|
38 | 68 |
The box can be opened modal (i.e. the currently active view will |
69 |
be suspended) or modeless. The default is modal (i.e. sending #open |
|
70 |
is equivalent to #openModal). |
|
242 | 71 |
|
72 |
Most of the above is also available via messages to Dialog for ST-80 compatibility |
|
73 |
(i.e. Dialog request:someString' is the same as EnterBox request:'someString') |
|
62 | 74 |
" |
75 |
! |
|
3 | 76 |
|
62 | 77 |
examples |
78 |
" |
|
242 | 79 |
examples (for ST-80 compatibility, please use Dialog messages): |
80 |
||
81 |
simple (most common): |
|
82 |
||
83 |
|someString| |
|
84 |
||
85 |
someString := EnterBox request:'enter a string'. |
|
86 |
Transcript showCr:someString |
|
59 | 87 |
|
242 | 88 |
creating first, setting actions and manually opening: |
89 |
||
90 |
|box| |
|
91 |
||
92 |
box := EnterBox new. |
|
93 |
box title:'your name please:'. |
|
94 |
box action:[:arg | Transcript showCr:'entered: ' , arg printString]. |
|
95 |
box open |
|
59 | 96 |
|
181 | 97 |
non-modal: |
242 | 98 |
|
99 |
|box| |
|
8 | 100 |
|
242 | 101 |
box := EnterBox new. |
102 |
box title:'your name please:'. |
|
103 |
box action:[:arg | Transcript showCr:'entered: ' , arg printString]. |
|
104 |
box openModeless |
|
59 | 105 |
|
242 | 106 |
for easier instance creation, there are also some combination methods: |
62 | 107 |
|
242 | 108 |
|box| |
62 | 109 |
|
242 | 110 |
box := EnterBox |
111 |
title:'your name please:' |
|
112 |
action:[:arg | Transcript showCr:'entered: ' , arg printString]. |
|
113 |
box openModeless |
|
62 | 114 |
|
59 | 115 |
If the box is needed to ask for a simple string, you can also use the |
116 |
#request method, to bring up a box, let it ask for something and return |
|
117 |
the entered string. This method will return nil, if the box was |
|
118 |
closed with the 'abort' button. |
|
119 |
Example: |
|
8 | 120 |
|
242 | 121 |
|box string| |
59 | 122 |
|
242 | 123 |
box := EnterBox request:'input some string:'. |
124 |
string isNil ifTrue:[ |
|
125 |
Transcript showCr:'no input' |
|
126 |
] ifFalse:[ |
|
127 |
Transcript showCr:('the entered string was: ' , string) |
|
128 |
] |
|
38 | 129 |
|
59 | 130 |
of course, this can be written shorter as: |
131 |
||
242 | 132 |
|string| |
59 | 133 |
|
242 | 134 |
string := EnterBox request:'input some string:'. |
135 |
string isNil ifTrue:[ |
|
136 |
Transcript showCr:'no input' |
|
137 |
] ifFalse:[ |
|
138 |
Transcript showCr:('the entered string was: ' , string) |
|
139 |
] |
|
181 | 140 |
|
141 |
||
142 |
A box for passwords is created with: |
|
143 |
||
242 | 144 |
|box| |
181 | 145 |
|
242 | 146 |
box := EnterBox |
147 |
title:'your name please:' |
|
148 |
action:[:arg | Transcript showCr:'entered: ' , arg printString]. |
|
149 |
box enterField passwordCharacter:$*. |
|
150 |
box showAtPointer |
|
181 | 151 |
|
152 |
or simply: |
|
153 |
||
242 | 154 |
|string| |
181 | 155 |
|
242 | 156 |
string := EnterBox requestPassword:'enter your password:'. |
157 |
Transcript showCr:string. |
|
3 | 158 |
" |
181 | 159 |
|
160 |
"Modified: 16.11.1995 / 21:28:11 / cg" |
|
3 | 161 |
! ! |
162 |
||
0 | 163 |
!EnterBox class methodsFor:'instance creation'! |
164 |
||
165 |
action:aBlock |
|
166 |
"create and return a new EnterBox |
|
167 |
which will evaluate aBlock when 'ok' is pressed" |
|
168 |
||
169 |
^ (self new) action:aBlock |
|
170 |
||
171 |
"(EnterBox action:[:string | Transcript showCr:string]) showAtPointer" |
|
172 |
! |
|
173 |
||
62 | 174 |
title:titleString |
175 |
"create and return a new EnterBox with title aString" |
|
176 |
||
177 |
^ self new title:titleString |
|
178 |
! |
|
179 |
||
101 | 180 |
title:titleString action:aBlock |
181 |
"create and return a new EnterBox with title aString, |
|
182 |
which will evaluate aBlock when 'ok' is pressed" |
|
183 |
||
184 |
^ (self title:titleString) action:aBlock |
|
185 |
! |
|
186 |
||
197 | 187 |
title:titleString okText:okText abortText:abortText action:aBlock |
188 |
"create and return a new EnterBox with title aString, and buttons showing |
|
189 |
okText and abortText; it will evaluate aBlock when 'ok' is pressed" |
|
190 |
||
191 |
^ (self title:titleString okText:okText action:aBlock) abortText:abortText |
|
192 |
! |
|
193 |
||
101 | 194 |
title:titleString okText:okText action:aBlock |
195 |
"create and return a new EnterBox with title aString, and ok button showing |
|
196 |
okText; it will evaluate aBlock when 'ok' is pressed" |
|
197 |
||
198 |
^ (self title:titleString action:aBlock) okText:okText |
|
77 | 199 |
! ! |
200 |
||
201 |
!EnterBox class methodsFor:'defaults'! |
|
202 |
||
197 | 203 |
defaultExtent |
204 |
^ (Screen current pixelPerMillimeter * (60 @ 30)) rounded |
|
205 |
! |
|
206 |
||
77 | 207 |
minExtent |
208 |
^ self defaultExtent |
|
209 |
! ! |
|
210 |
||
211 |
!EnterBox class methodsFor:'easy startup '! |
|
212 |
||
213 |
request:aTitle |
|
214 |
"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
|
215 |
Return the enterred string or an empty string (if abort was pressed). |
77 | 216 |
The string may be empty, in case return was pressed immediately." |
217 |
||
218 |
^ self new request:aTitle |
|
219 |
||
220 |
" |
|
221 |
EnterBox request:'enter a string' |
|
222 |
" |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
223 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
224 |
"Modified: 27.1.1996 / 14:34:23 / cg" |
181 | 225 |
! |
226 |
||
227 |
requestPassword:aTitle |
|
228 |
"create and show an enterBox asking for aTitle. |
|
229 |
The box is setup to NOT display entered characters (as with password entry). |
|
230 |
Return the entered string or nil (if abort was pressed). |
|
231 |
The string may be empty, in case return was pressed immediately." |
|
232 |
||
233 |
^ self new requestPassword:aTitle |
|
234 |
||
235 |
" |
|
236 |
|s| |
|
237 |
||
238 |
s := EnterBox requestPassword:'enter a string'. |
|
239 |
Transcript showCr:'you entered: ' , s |
|
240 |
" |
|
241 |
||
242 |
"Created: 16.11.1995 / 21:25:08 / cg" |
|
77 | 243 |
! ! |
244 |
||
245 |
!EnterBox methodsFor:'accessing'! |
|
246 |
||
247 |
contents |
|
248 |
"return my contents" |
|
249 |
||
250 |
^ enterField contents |
|
251 |
! |
|
252 |
||
144 | 253 |
contents:aString |
254 |
"set my contents" |
|
255 |
||
256 |
enterField contents:aString |
|
257 |
! |
|
258 |
||
197 | 259 |
enterField |
260 |
"provide access to the entryfield" |
|
261 |
||
262 |
^ enterField |
|
263 |
||
264 |
"Created: 16.11.1995 / 21:23:48 / cg" |
|
265 |
! |
|
266 |
||
267 |
entryCompletionBlock:aBlock |
|
268 |
enterField entryCompletionBlock:aBlock |
|
269 |
! |
|
270 |
||
77 | 271 |
initialText:aString |
272 |
"define the initial text in the enterfield. all will be selected initially" |
|
273 |
||
274 |
enterField initialText:aString |
|
275 |
! |
|
276 |
||
197 | 277 |
initialText:aString selectFrom:start to:stop |
278 |
"define the initial text in the enterfield, and the part to be selected" |
|
279 |
||
280 |
enterField initialText:aString. |
|
281 |
enterField selectFromLine:1 col:start toLine:1 col:stop |
|
282 |
! |
|
283 |
||
284 |
labelField |
|
285 |
"provide access to the labelfield" |
|
286 |
||
287 |
^ labelField |
|
288 |
||
289 |
"Created: 16.11.1995 / 21:23:48 / cg" |
|
144 | 290 |
! |
291 |
||
77 | 292 |
title:aString |
293 |
"set the title to be displayed at top of enterBox" |
|
294 |
||
295 |
|oldSize| |
|
296 |
||
297 |
aString ~= labelField label ifTrue:[ |
|
298 |
oldSize := labelField extent. |
|
299 |
labelField label:aString. |
|
110 | 300 |
labelField forceResize. |
77 | 301 |
|
118 | 302 |
shown ifTrue:[ |
303 |
labelField extent ~= oldSize ifTrue:[ |
|
304 |
self resize |
|
305 |
] |
|
77 | 306 |
] |
307 |
] |
|
308 |
! |
|
309 |
||
310 |
title:titleString okText:okString |
|
311 |
"set title and text in okbutton" |
|
312 |
||
313 |
(titleString ~= labelField label or:[okString ~= okButton label]) ifTrue:[ |
|
314 |
okButton label:okString. |
|
315 |
okButton resize. |
|
316 |
labelField label:titleString. |
|
110 | 317 |
labelField forceResize. |
97 | 318 |
shown ifTrue:[self resize]. |
77 | 319 |
] |
320 |
! |
|
321 |
||
322 |
title:titleString okText:okString abortText:abortString |
|
323 |
"set title and texts in the buttons" |
|
324 |
||
325 |
(titleString ~= labelField label |
|
326 |
or:[okString ~= okButton label |
|
327 |
or:[abortString ~= abortButton label]]) ifTrue:[ |
|
328 |
okButton label:okString. |
|
329 |
okButton resize. |
|
330 |
abortButton label:abortString. |
|
331 |
abortButton resize. |
|
332 |
labelField label:titleString. |
|
110 | 333 |
labelField forceResize. |
97 | 334 |
shown ifTrue:[self resize]. |
77 | 335 |
] |
197 | 336 |
! ! |
181 | 337 |
|
197 | 338 |
!EnterBox methodsFor:'change & update'! |
181 | 339 |
|
197 | 340 |
update:something with:someArgument from:changedObject |
341 |
"sent if my enterbox thinks it needs more real-estate ..." |
|
181 | 342 |
|
197 | 343 |
changedObject == enterField ifTrue:[ |
344 |
something == #preferredExtent ifTrue:[ |
|
345 |
shown ifTrue:[self resizeUnderPointer]. |
|
346 |
^ self |
|
347 |
] |
|
348 |
]. |
|
349 |
super update:something with:someArgument from:changedObject |
|
0 | 350 |
! ! |
351 |
||
352 |
!EnterBox methodsFor:'initialization'! |
|
353 |
||
77 | 354 |
createEnterField |
355 |
"this has been extracted from the initialize method |
|
121 | 356 |
to allow redefinition in subclasses. (FilenameEnterBox for example). |
357 |
It shall return a new instance of the desired editField class." |
|
77 | 358 |
|
121 | 359 |
^ EditField new. |
77 | 360 |
! |
361 |
||
197 | 362 |
focusSequence |
363 |
^ Array with:enterField with:abortButton with:okButton |
|
364 |
! |
|
365 |
||
0 | 366 |
initialize |
90 | 367 |
|space2 innerWidth| |
0 | 368 |
|
369 |
super initialize. |
|
370 |
||
77 | 371 |
self addAbortButton; addOkButton. |
372 |
||
150 | 373 |
label := resources string:'Enter'. |
73 | 374 |
|
0 | 375 |
space2 := 2 * ViewSpacing. |
73 | 376 |
innerWidth := width - space2. |
0 | 377 |
|
378 |
labelField := Label in:self. |
|
118 | 379 |
labelField |
380 |
label:''; |
|
381 |
borderWidth:0; |
|
382 |
adjust:#left; |
|
383 |
origin:(0.0 @ ViewSpacing) extent:[1.0 @ labelField height]; |
|
384 |
leftInset:ViewSpacing; |
|
385 |
rightInset:ViewSpacing. |
|
0 | 386 |
|
121 | 387 |
self addComponent:(enterField := self createEnterField). |
118 | 388 |
enterField |
130 | 389 |
origin:[0.0 @ (space2 + labelField preferredExtent y "height")] |
139 | 390 |
extent:(1.0 @ enterField height). |
118 | 391 |
enterField |
139 | 392 |
leftInset:ViewSpacing-enterField borderWidth; |
118 | 393 |
rightInset:ViewSpacing; |
394 |
leaveAction:[:key | self okPressed]. |
|
395 |
||
130 | 396 |
enterField addDependent:self. "to get preferredExtent-changes" |
0 | 397 |
|
59 | 398 |
" |
399 |
forward keyboard input to the enterfield |
|
400 |
" |
|
122 | 401 |
self delegate:(KeyboardForwarder toView:enterField condition:#noFocus). |
121 | 402 |
enterField hasKeyboardFocus:true. |
0 | 403 |
! |
404 |
||
405 |
reAdjustGeometry |
|
406 |
"sent late in snapin processing - gives me a chance |
|
407 |
to resize for new font dimensions" |
|
408 |
||
409 |
super reAdjustGeometry. |
|
410 |
labelField resize. |
|
411 |
okButton resize. |
|
412 |
abortButton resize. |
|
413 |
self resize |
|
59 | 414 |
! ! |
415 |
||
62 | 416 |
!EnterBox methodsFor:'queries'! |
0 | 417 |
|
130 | 418 |
preferredExtent |
110 | 419 |
|wWanted hWanted wPanel vs2 min |
420 |
labelPref enterPref panelPref| |
|
59 | 421 |
|
130 | 422 |
panelPref := buttonPanel preferredExtent. |
423 |
labelPref := labelField preferredExtent. |
|
424 |
enterPref := enterField preferredExtent. |
|
110 | 425 |
wWanted := (labelPref x max:enterPref x). |
426 |
wPanel := panelPref x. |
|
59 | 427 |
wPanel > wWanted ifTrue:[ |
428 |
wWanted := wPanel |
|
429 |
]. |
|
110 | 430 |
|
431 |
hWanted := labelPref y + enterPref y + |
|
73 | 432 |
(ViewSpacing * 6) + panelPref y + ViewSpacing. |
59 | 433 |
|
434 |
min := self class minExtent. |
|
435 |
wWanted < min x ifTrue:[ |
|
436 |
wWanted := min x |
|
437 |
]. |
|
438 |
hWanted < min y ifTrue:[ |
|
439 |
hWanted := min y |
|
440 |
]. |
|
110 | 441 |
vs2 := ViewSpacing * 2. |
442 |
^ (wWanted + vs2) @ (hWanted + vs2) |
|
0 | 443 |
! ! |
444 |
||
77 | 445 |
!EnterBox methodsFor:'startup'! |
446 |
||
447 |
request |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
448 |
"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
|
449 |
or an empty string, if abort was pressed" |
77 | 450 |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
451 |
^ self requestOnCancel:'' |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
452 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
453 |
"Modified: 27.1.1996 / 14:50:01 / cg" |
0 | 454 |
! |
455 |
||
77 | 456 |
request:title |
242 | 457 |
"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
|
458 |
or the empty string, if abort was pressed." |
0 | 459 |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
460 |
^ self request:title onCancel:'' |
242 | 461 |
|
462 |
" |
|
463 |
EnterBox request:'enter some string:' |
|
464 |
||
465 |
|bx| |
|
466 |
bx := EnterBox new. |
|
467 |
bx label:'foo bar baz'. |
|
468 |
bx request:'enter some string:' |
|
469 |
" |
|
470 |
||
471 |
"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
|
472 |
"Modified: 27.1.1996 / 14:49:23 / cg" |
181 | 473 |
! |
474 |
||
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
475 |
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
|
476 |
"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
|
477 |
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
|
478 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
479 |
self title:title. |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
480 |
^ self requestOnCancel:cancelValue |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
481 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
482 |
" |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
483 |
EnterBox request:'enter some string:' onCancel:nil |
181 | 484 |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
485 |
|bx| |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
486 |
bx := EnterBox new. |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
487 |
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
|
488 |
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
|
489 |
" |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
490 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
491 |
"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
|
492 |
"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
|
493 |
! |
181 | 494 |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
495 |
requestOnCancel:cancelValue |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
496 |
"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
|
497 |
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
|
498 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
499 |
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
|
500 |
self open. |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
501 |
^ cancelValue value |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
502 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
503 |
"Created: 27.1.1996 / 14:47:47 / cg" |
181 | 504 |
! |
505 |
||
506 |
requestPassword:title |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
507 |
"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
|
508 |
or an empty string, 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
|
509 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
510 |
^ self requestPassword:title onCancel:'' |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
511 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
512 |
"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
|
513 |
"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
|
514 |
! |
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
515 |
|
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
516 |
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
|
517 |
"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
|
518 |
or cancelValue, if abort was pressed" |
181 | 519 |
|
520 |
enterField passwordCharacter:$*. |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
521 |
^ self request:title onCancel:cancelValue |
181 | 522 |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
523 |
"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
|
524 |
"Created: 27.1.1996 / 14:52:13 / cg" |
77 | 525 |
! ! |
197 | 526 |
|
527 |
!EnterBox methodsFor:'user actions'! |
|
528 |
||
529 |
hideAndEvaluate:aBlock |
|
530 |
"common processing for all ok-actions (see subclasses); |
|
531 |
if modal, shut down box. |
|
532 |
Then fetch entered string and evaluate the passed action with it" |
|
533 |
||
534 |
|string| |
|
535 |
||
536 |
(windowGroup notNil and:[windowGroup isModal]) ifTrue:[ |
|
537 |
self hide. |
|
538 |
]. |
|
539 |
aBlock notNil ifTrue:[ |
|
540 |
string := self contents. |
|
541 |
string isNil ifTrue:[ |
|
542 |
string := '' |
|
543 |
] ifFalse:[ |
|
544 |
string := string withoutSeparators |
|
545 |
]. |
|
546 |
aBlock value:string |
|
547 |
] |
|
548 |
! ! |
|
549 |
||
242 | 550 |
!EnterBox class methodsFor:'documentation'! |
551 |
||
552 |
version |
|
306
6a6a1513b713
changed cancel-value to '' (ST-80 compat.); added xxx:onCancel: methods
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
553 |
^ '$Header: /cvs/stx/stx/libwidg/EnterBox.st,v 1.35 1996-01-27 14:15:17 cg Exp $' |
242 | 554 |
! ! |