author | Claus Gittinger <cg@exept.de> |
Thu, 23 Nov 1995 01:50:10 +0100 | |
changeset 193 | 6ccc226ce3a6 |
parent 174 | d80a6cc3f9b2 |
child 197 | 00927189c882 |
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 |
|
14 |
instanceVariableNames:'okButton2 okAction2' |
|
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
38 | 17 |
category:'Views-DialogBoxes' |
0 | 18 |
! |
19 |
||
38 | 20 |
!EnterBox2 class methodsFor:'documentation '! |
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
59 | 25 |
All Rights Reserved |
0 | 26 |
|
38 | 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 |
! |
|
0 | 35 |
|
38 | 36 |
version |
174
d80a6cc3f9b2
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
97
diff
changeset
|
37 |
^ '$Header: /cvs/stx/stx/libwidg/EnterBox2.st,v 1.12 1995-11-11 16:20:13 cg Exp $' |
38 | 38 |
! |
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
An EnterBox2 is like an EnterBox but with 2 action buttons. |
|
43 |
This is used (for example) in the search-boxes, where two ok-buttons |
|
44 |
'find-previous' and 'find-next' are needed in addition to the abort button. |
|
60 | 45 |
The protocol is like that of EnterBox, the additional buttons label |
46 |
can be set with 'okText2:aString' and its action with 'action2:aBlock'. |
|
38 | 47 |
" |
48 |
! ! |
|
0 | 49 |
|
50 |
!EnterBox2 class methodsFor:'instance creation'! |
|
51 |
||
52 |
title:titleString okText1:text1 okText2:text2 abortText:abortText |
|
59 | 53 |
action1:block1 action2:block2 |
0 | 54 |
"create and return a new EnterBox-with-2 buttons |
55 |
and define its text, button-labels and actions" |
|
56 |
||
57 |
^ (super title:titleString |
|
59 | 58 |
okText:text1 |
59 |
abortText:abortText |
|
60 |
action:block1) okText2:text2 action2:block2 |
|
0 | 61 |
! ! |
62 |
||
63 |
!EnterBox2 methodsFor:'initialization'! |
|
64 |
||
65 |
initialize |
|
66 |
super initialize. |
|
67 |
||
59 | 68 |
" |
69 |
add a second ok-button |
|
70 |
" |
|
71 |
okButton2 := Button okButtonIn:buttonPanel. |
|
95 | 72 |
okButton2 model:self; change:#ok2Pressed. |
73 |
||
59 | 74 |
" |
77 | 75 |
the old (see superclass) ok-button is no longer a return-button |
59 | 76 |
" |
0 | 77 |
okButton isReturnButton:false. |
48 | 78 |
|
0 | 79 |
enterField leaveAction:[:key | self ok2Pressed] |
77 | 80 |
! |
81 |
||
82 |
focusSequence |
|
83 |
^ Array with:enterField with:abortButton with:okButton with:okButton2 |
|
0 | 84 |
! ! |
85 |
||
8 | 86 |
!EnterBox2 methodsFor:'realization'! |
87 |
||
88 |
positionOffset |
|
89 |
"return the delta, by which the box should be displayed |
|
90 |
from the mouse pointer. Value returned here makes |
|
91 |
okButton appear under the cursor" |
|
92 |
||
60 | 93 |
buttonPanel setChildPositionsIfChanged. |
8 | 94 |
^ (okButton2 originRelativeTo:self) + (okButton2 extent // 2) |
95 |
! ! |
|
96 |
||
0 | 97 |
!EnterBox2 methodsFor:'accessing'! |
98 |
||
99 |
okText2:aString action2:aBlock |
|
100 |
"set the text to be displayed in the 2nd ok-button, |
|
101 |
and its action" |
|
102 |
||
103 |
self okText2:aString. |
|
104 |
okAction2 := aBlock |
|
105 |
! |
|
106 |
||
107 |
okText2:aString |
|
108 |
"set the text to be displayed in the 2nd ok-button" |
|
109 |
||
8 | 110 |
aString ~= okButton2 label ifTrue:[ |
59 | 111 |
okButton2 label:aString. |
112 |
okButton2 resize. |
|
97 | 113 |
shown ifTrue:[self resize] |
8 | 114 |
] |
0 | 115 |
! |
116 |
||
117 |
action2:aBlock |
|
118 |
"set the action to be performed when user presses the 2nd ok-button; |
|
119 |
aBlock must be nil or a block with one argument " |
|
120 |
||
121 |
okAction2 := aBlock |
|
122 |
! ! |
|
123 |
||
124 |
!EnterBox2 methodsFor:'user interaction'! |
|
125 |
||
126 |
ok2Pressed |
|
127 |
"user pressed 2nd ok button - evaluate action" |
|
128 |
||
95 | 129 |
okButton2 turnOffWithoutRedraw. |
0 | 130 |
self hideAndEvaluate:okAction2 |
77 | 131 |
! |
132 |
||
133 |
keyPress:aKey x:x y:y |
|
134 |
"return-key dublicates ok-function if acceptReturnAsOK is true" |
|
135 |
||
136 |
acceptReturnAsOK ifTrue:[ |
|
137 |
(aKey == #Return) ifTrue:[^ self ok2Pressed] |
|
138 |
]. |
|
139 |
super keyPress:aKey x:x y:y |
|
0 | 140 |
! ! |