author | Claus Gittinger <cg@exept.de> |
Tue, 25 Feb 2003 16:00:36 +0100 | |
changeset 2698 | cca702636705 |
parent 2697 | 62d6c6b7a2a2 |
child 2701 | b77cc7cf3818 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1991 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 |
||
2448 | 13 |
"{ Package: 'stx:libwidg' }" |
14 |
||
0 | 15 |
EnterBox subclass:#EnterBox2 |
355 | 16 |
instanceVariableNames:'okButton2 okAction2' |
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'Views-DialogBoxes' |
|
0 | 20 |
! |
21 |
||
2448 | 22 |
!EnterBox2 class methodsFor:'documentation'! |
38 | 23 |
|
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
59 | 27 |
All Rights Reserved |
0 | 28 |
|
38 | 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 |
! |
|
0 | 37 |
|
38 | 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 |
||
38 | 50 |
An EnterBox2 is like an EnterBox but with 2 action buttons. |
51 |
This is used (for example) in the search-boxes, where two ok-buttons |
|
52 |
'find-previous' and 'find-next' are needed in addition to the abort button. |
|
60 | 53 |
The protocol is like that of EnterBox, the additional buttons label |
54 |
can be set with 'okText2:aString' and its action with 'action2:aBlock'. |
|
585 | 55 |
|
56 |
[author:] |
|
57 |
Claus Gittinger |
|
58 |
||
59 |
[see also:] |
|
60 |
DialogBox |
|
61 |
EnterBox YesNoBox |
|
62 |
ListSelectionBox FileSelectionBox FileSaveBox |
|
38 | 63 |
" |
355 | 64 |
|
585 | 65 |
"Modified: 25.4.1996 / 16:47:41 / cg" |
2448 | 66 |
! ! |
67 |
||
68 |
!EnterBox2 class methodsFor:'instance creation'! |
|
197 | 69 |
|
2448 | 70 |
title:titleString okText1:text1 okText2:text2 abortText:abortText |
71 |
action1:block1 action2:block2 |
|
72 |
"create and return a new EnterBox-with-2 buttons |
|
73 |
and define its text, button-labels and actions" |
|
74 |
||
75 |
^ (super title:titleString |
|
76 |
okText:text1 |
|
77 |
abortText:abortText |
|
78 |
action:block1) okText2:text2 action2:block2 |
|
38 | 79 |
! ! |
0 | 80 |
|
197 | 81 |
!EnterBox2 methodsFor:'accessing'! |
82 |
||
83 |
action2:aBlock |
|
84 |
"set the action to be performed when user presses the 2nd ok-button; |
|
85 |
aBlock must be nil or a block with one argument " |
|
86 |
||
87 |
okAction2 := aBlock |
|
88 |
! |
|
89 |
||
90 |
okText2:aString |
|
91 |
"set the text to be displayed in the 2nd ok-button" |
|
0 | 92 |
|
197 | 93 |
aString ~= okButton2 label ifTrue:[ |
94 |
okButton2 label:aString. |
|
95 |
okButton2 resize. |
|
96 |
shown ifTrue:[self resize] |
|
97 |
] |
|
98 |
! |
|
0 | 99 |
|
197 | 100 |
okText2:aString action2:aBlock |
101 |
"set the text to be displayed in the 2nd ok-button, |
|
102 |
and its action" |
|
103 |
||
104 |
self okText2:aString. |
|
105 |
okAction2 := aBlock |
|
0 | 106 |
! ! |
107 |
||
108 |
!EnterBox2 methodsFor:'initialization'! |
|
109 |
||
110 |
initialize |
|
111 |
super initialize. |
|
112 |
||
59 | 113 |
" |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
114 |
add a second ok-button (a return button) |
59 | 115 |
" |
1760
631f902aaabe
care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
116 |
okButton2 := Button okButton. |
2698 | 117 |
Dialog defaultOKButtonAtLeft ifTrue:[ |
1760
631f902aaabe
care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
118 |
buttonPanel addSubView:okButton2 before:okButton. |
631f902aaabe
care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
119 |
] ifFalse:[ |
631f902aaabe
care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
120 |
buttonPanel addSubView:okButton2 after:okButton. |
631f902aaabe
care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
121 |
]. |
95 | 122 |
okButton2 model:self; change:#ok2Pressed. |
123 |
||
59 | 124 |
" |
77 | 125 |
the old (see superclass) ok-button is no longer a return-button |
59 | 126 |
" |
0 | 127 |
okButton isReturnButton:false. |
48 | 128 |
|
0 | 129 |
enterField leaveAction:[:key | self ok2Pressed] |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
130 |
|
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
131 |
"Modified: 31.5.1996 / 21:55:57 / cg" |
0 | 132 |
! ! |
133 |
||
134 |
!EnterBox2 methodsFor:'user interaction'! |
|
135 |
||
77 | 136 |
keyPress:aKey x:x y:y |
137 |
"return-key dublicates ok-function if acceptReturnAsOK is true" |
|
138 |
||
490 | 139 |
<resource: #keyboard (#Return)> |
140 |
||
77 | 141 |
acceptReturnAsOK ifTrue:[ |
490 | 142 |
(aKey == #Return) ifTrue:[^ self ok2Pressed] |
77 | 143 |
]. |
144 |
super keyPress:aKey x:x y:y |
|
490 | 145 |
|
146 |
"Modified: 7.3.1996 / 13:16:37 / cg" |
|
197 | 147 |
! |
148 |
||
149 |
ok2Pressed |
|
150 |
"user pressed 2nd ok button - evaluate action" |
|
151 |
||
152 |
okButton2 turnOffWithoutRedraw. |
|
153 |
self hideAndEvaluate:okAction2 |
|
0 | 154 |
! ! |
197 | 155 |
|
2448 | 156 |
!EnterBox2 class methodsFor:'documentation'! |
157 |
||
158 |
version |
|
2698 | 159 |
^ '$Header: /cvs/stx/stx/libwidg/EnterBox2.st,v 1.24 2003-02-25 14:58:23 cg Exp $' |
2448 | 160 |
! ! |