author | Claus Gittinger <cg@exept.de> |
Sat, 06 Mar 1999 04:04:04 +0100 | |
changeset 1764 | 45ca6b617934 |
parent 1760 | 631f902aaabe |
child 2040 | 7e2052cb0c8c |
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 |
||
13 |
EnterBox subclass:#EnterBox2 |
|
355 | 14 |
instanceVariableNames:'okButton2 okAction2' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Views-DialogBoxes' |
|
0 | 18 |
! |
19 |
||
197 | 20 |
!EnterBox2 class methodsFor:'instance creation'! |
21 |
||
22 |
title:titleString okText1:text1 okText2:text2 abortText:abortText |
|
23 |
action1:block1 action2:block2 |
|
24 |
"create and return a new EnterBox-with-2 buttons |
|
25 |
and define its text, button-labels and actions" |
|
26 |
||
27 |
^ (super title:titleString |
|
28 |
okText:text1 |
|
29 |
abortText:abortText |
|
30 |
action:block1) okText2:text2 action2:block2 |
|
31 |
! ! |
|
32 |
||
38 | 33 |
!EnterBox2 class methodsFor:'documentation '! |
34 |
||
35 |
copyright |
|
36 |
" |
|
37 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
59 | 38 |
All Rights Reserved |
0 | 39 |
|
38 | 40 |
This software is furnished under a license and may be used |
41 |
only in accordance with the terms of that license and with the |
|
42 |
inclusion of the above copyright notice. This software may not |
|
43 |
be provided or otherwise made available to, or used by, any |
|
44 |
other person. No title to or ownership of the software is |
|
45 |
hereby transferred. |
|
46 |
" |
|
47 |
! |
|
0 | 48 |
|
38 | 49 |
documentation |
50 |
" |
|
355 | 51 |
Historic note: |
52 |
originally, ST/X had separate classes for the various entry methods; |
|
53 |
there were YesNoBox, EnterBox, InfoBox and so on. |
|
54 |
In the meantime, the DialogBox class (and therefore its alias: Dialog) |
|
55 |
is going to duplicate most funcionality found in these classes. |
|
56 |
||
57 |
In the future, those existing subclasses' functionality is going to |
|
58 |
be moved fully into Dialog, and the subclasses will be replaced by dummy |
|
59 |
delegators. (They will be kept for backward compatibility, though). |
|
60 |
||
38 | 61 |
An EnterBox2 is like an EnterBox but with 2 action buttons. |
62 |
This is used (for example) in the search-boxes, where two ok-buttons |
|
63 |
'find-previous' and 'find-next' are needed in addition to the abort button. |
|
60 | 64 |
The protocol is like that of EnterBox, the additional buttons label |
65 |
can be set with 'okText2:aString' and its action with 'action2:aBlock'. |
|
585 | 66 |
|
67 |
[author:] |
|
68 |
Claus Gittinger |
|
69 |
||
70 |
[see also:] |
|
71 |
DialogBox |
|
72 |
EnterBox YesNoBox |
|
73 |
ListSelectionBox FileSelectionBox FileSaveBox |
|
38 | 74 |
" |
355 | 75 |
|
585 | 76 |
"Modified: 25.4.1996 / 16:47:41 / cg" |
197 | 77 |
! |
78 |
||
79 |
version |
|
1764 | 80 |
^ '$Header: /cvs/stx/stx/libwidg/EnterBox2.st,v 1.20 1999-03-06 03:03:56 cg Exp $' |
38 | 81 |
! ! |
0 | 82 |
|
197 | 83 |
!EnterBox2 methodsFor:'accessing'! |
84 |
||
85 |
action2:aBlock |
|
86 |
"set the action to be performed when user presses the 2nd ok-button; |
|
87 |
aBlock must be nil or a block with one argument " |
|
88 |
||
89 |
okAction2 := aBlock |
|
90 |
! |
|
91 |
||
92 |
okText2:aString |
|
93 |
"set the text to be displayed in the 2nd ok-button" |
|
0 | 94 |
|
197 | 95 |
aString ~= okButton2 label ifTrue:[ |
96 |
okButton2 label:aString. |
|
97 |
okButton2 resize. |
|
98 |
shown ifTrue:[self resize] |
|
99 |
] |
|
100 |
! |
|
0 | 101 |
|
197 | 102 |
okText2:aString action2:aBlock |
103 |
"set the text to be displayed in the 2nd ok-button, |
|
104 |
and its action" |
|
105 |
||
106 |
self okText2:aString. |
|
107 |
okAction2 := aBlock |
|
0 | 108 |
! ! |
109 |
||
110 |
!EnterBox2 methodsFor:'initialization'! |
|
111 |
||
112 |
initialize |
|
1764 | 113 |
<resource: #style (#'dialogBox.okAtLeft')> |
114 |
||
0 | 115 |
super initialize. |
116 |
||
59 | 117 |
" |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
118 |
add a second ok-button (a return button) |
59 | 119 |
" |
1760
631f902aaabe
care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
120 |
okButton2 := Button okButton. |
1764 | 121 |
(styleSheet at:'dialogBox.okAtLeft'default:false) ifTrue:[ |
1760
631f902aaabe
care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
122 |
buttonPanel addSubView:okButton2 before:okButton. |
631f902aaabe
care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
123 |
] ifFalse:[ |
631f902aaabe
care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
124 |
buttonPanel addSubView:okButton2 after:okButton. |
631f902aaabe
care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
125 |
]. |
95 | 126 |
okButton2 model:self; change:#ok2Pressed. |
127 |
||
59 | 128 |
" |
77 | 129 |
the old (see superclass) ok-button is no longer a return-button |
59 | 130 |
" |
0 | 131 |
okButton isReturnButton:false. |
48 | 132 |
|
0 | 133 |
enterField leaveAction:[:key | self ok2Pressed] |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
134 |
|
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
135 |
"Modified: 31.5.1996 / 21:55:57 / cg" |
0 | 136 |
! ! |
137 |
||
138 |
!EnterBox2 methodsFor:'user interaction'! |
|
139 |
||
77 | 140 |
keyPress:aKey x:x y:y |
141 |
"return-key dublicates ok-function if acceptReturnAsOK is true" |
|
142 |
||
490 | 143 |
<resource: #keyboard (#Return)> |
144 |
||
77 | 145 |
acceptReturnAsOK ifTrue:[ |
490 | 146 |
(aKey == #Return) ifTrue:[^ self ok2Pressed] |
77 | 147 |
]. |
148 |
super keyPress:aKey x:x y:y |
|
490 | 149 |
|
150 |
"Modified: 7.3.1996 / 13:16:37 / cg" |
|
197 | 151 |
! |
152 |
||
153 |
ok2Pressed |
|
154 |
"user pressed 2nd ok button - evaluate action" |
|
155 |
||
156 |
okButton2 turnOffWithoutRedraw. |
|
157 |
self hideAndEvaluate:okAction2 |
|
0 | 158 |
! ! |
197 | 159 |