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'.
|
38
|
66 |
"
|
355
|
67 |
|
|
68 |
"Modified: 10.2.1996 / 18:00:28 / cg"
|
197
|
69 |
!
|
|
70 |
|
|
71 |
version
|
355
|
72 |
^ '$Header: /cvs/stx/stx/libwidg/EnterBox2.st,v 1.14 1996-02-11 09:54:43 cg Exp $'
|
38
|
73 |
! !
|
0
|
74 |
|
197
|
75 |
!EnterBox2 methodsFor:'accessing'!
|
|
76 |
|
|
77 |
action2:aBlock
|
|
78 |
"set the action to be performed when user presses the 2nd ok-button;
|
|
79 |
aBlock must be nil or a block with one argument "
|
|
80 |
|
|
81 |
okAction2 := aBlock
|
|
82 |
!
|
|
83 |
|
|
84 |
okText2:aString
|
|
85 |
"set the text to be displayed in the 2nd ok-button"
|
0
|
86 |
|
197
|
87 |
aString ~= okButton2 label ifTrue:[
|
|
88 |
okButton2 label:aString.
|
|
89 |
okButton2 resize.
|
|
90 |
shown ifTrue:[self resize]
|
|
91 |
]
|
|
92 |
!
|
0
|
93 |
|
197
|
94 |
okText2:aString action2:aBlock
|
|
95 |
"set the text to be displayed in the 2nd ok-button,
|
|
96 |
and its action"
|
|
97 |
|
|
98 |
self okText2:aString.
|
|
99 |
okAction2 := aBlock
|
0
|
100 |
! !
|
|
101 |
|
|
102 |
!EnterBox2 methodsFor:'initialization'!
|
|
103 |
|
197
|
104 |
focusSequence
|
|
105 |
^ Array with:enterField with:abortButton with:okButton with:okButton2
|
|
106 |
!
|
|
107 |
|
0
|
108 |
initialize
|
|
109 |
super initialize.
|
|
110 |
|
59
|
111 |
"
|
|
112 |
add a second ok-button
|
|
113 |
"
|
|
114 |
okButton2 := Button okButtonIn:buttonPanel.
|
95
|
115 |
okButton2 model:self; change:#ok2Pressed.
|
|
116 |
|
59
|
117 |
"
|
77
|
118 |
the old (see superclass) ok-button is no longer a return-button
|
59
|
119 |
"
|
0
|
120 |
okButton isReturnButton:false.
|
48
|
121 |
|
0
|
122 |
enterField leaveAction:[:key | self ok2Pressed]
|
|
123 |
! !
|
|
124 |
|
8
|
125 |
!EnterBox2 methodsFor:'realization'!
|
|
126 |
|
|
127 |
positionOffset
|
|
128 |
"return the delta, by which the box should be displayed
|
|
129 |
from the mouse pointer. Value returned here makes
|
|
130 |
okButton appear under the cursor"
|
|
131 |
|
60
|
132 |
buttonPanel setChildPositionsIfChanged.
|
8
|
133 |
^ (okButton2 originRelativeTo:self) + (okButton2 extent // 2)
|
|
134 |
! !
|
|
135 |
|
0
|
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 |
|
|
141 |
acceptReturnAsOK ifTrue:[
|
|
142 |
(aKey == #Return) ifTrue:[^ self ok2Pressed]
|
|
143 |
].
|
|
144 |
super keyPress:aKey x:x y:y
|
197
|
145 |
!
|
|
146 |
|
|
147 |
ok2Pressed
|
|
148 |
"user pressed 2nd ok button - evaluate action"
|
|
149 |
|
|
150 |
okButton2 turnOffWithoutRedraw.
|
|
151 |
self hideAndEvaluate:okAction2
|
0
|
152 |
! !
|
197
|
153 |
|