author | Claus Gittinger <cg@exept.de> |
Wed, 10 Apr 2002 12:50:18 +0200 | |
changeset 2527 | 3e7d9eaa347b |
parent 2448 | 425e9a7d369d |
child 2697 | 62d6c6b7a2a2 |
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 |
|
1764 | 111 |
<resource: #style (#'dialogBox.okAtLeft')> |
112 |
||
0 | 113 |
super initialize. |
114 |
||
59 | 115 |
" |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
116 |
add a second ok-button (a return button) |
59 | 117 |
" |
1760
631f902aaabe
care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
118 |
okButton2 := Button okButton. |
2040 | 119 |
(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
|
120 |
buttonPanel addSubView:okButton2 before:okButton. |
631f902aaabe
care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
121 |
] ifFalse:[ |
631f902aaabe
care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
122 |
buttonPanel addSubView:okButton2 after:okButton. |
631f902aaabe
care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
123 |
]. |
95 | 124 |
okButton2 model:self; change:#ok2Pressed. |
125 |
||
59 | 126 |
" |
77 | 127 |
the old (see superclass) ok-button is no longer a return-button |
59 | 128 |
" |
0 | 129 |
okButton isReturnButton:false. |
48 | 130 |
|
0 | 131 |
enterField leaveAction:[:key | self ok2Pressed] |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
132 |
|
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
133 |
"Modified: 31.5.1996 / 21:55:57 / cg" |
0 | 134 |
! ! |
135 |
||
136 |
!EnterBox2 methodsFor:'user interaction'! |
|
137 |
||
77 | 138 |
keyPress:aKey x:x y:y |
139 |
"return-key dublicates ok-function if acceptReturnAsOK is true" |
|
140 |
||
490 | 141 |
<resource: #keyboard (#Return)> |
142 |
||
77 | 143 |
acceptReturnAsOK ifTrue:[ |
490 | 144 |
(aKey == #Return) ifTrue:[^ self ok2Pressed] |
77 | 145 |
]. |
146 |
super keyPress:aKey x:x y:y |
|
490 | 147 |
|
148 |
"Modified: 7.3.1996 / 13:16:37 / cg" |
|
197 | 149 |
! |
150 |
||
151 |
ok2Pressed |
|
152 |
"user pressed 2nd ok button - evaluate action" |
|
153 |
||
154 |
okButton2 turnOffWithoutRedraw. |
|
155 |
self hideAndEvaluate:okAction2 |
|
0 | 156 |
! ! |
197 | 157 |
|
2448 | 158 |
!EnterBox2 class methodsFor:'documentation'! |
159 |
||
160 |
version |
|
161 |
^ '$Header: /cvs/stx/stx/libwidg/EnterBox2.st,v 1.22 2001-10-18 16:49:42 cg Exp $' |
|
162 |
! ! |