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
|
197
|
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 |
"
|
|
51 |
An EnterBox2 is like an EnterBox but with 2 action buttons.
|
|
52 |
This is used (for example) in the search-boxes, where two ok-buttons
|
|
53 |
'find-previous' and 'find-next' are needed in addition to the abort button.
|
60
|
54 |
The protocol is like that of EnterBox, the additional buttons label
|
|
55 |
can be set with 'okText2:aString' and its action with 'action2:aBlock'.
|
38
|
56 |
"
|
197
|
57 |
!
|
|
58 |
|
|
59 |
version
|
|
60 |
^ '$Header: /cvs/stx/stx/libwidg/EnterBox2.st,v 1.13 1995-11-23 02:25:05 cg Exp $'
|
38
|
61 |
! !
|
0
|
62 |
|
197
|
63 |
!EnterBox2 methodsFor:'accessing'!
|
|
64 |
|
|
65 |
action2:aBlock
|
|
66 |
"set the action to be performed when user presses the 2nd ok-button;
|
|
67 |
aBlock must be nil or a block with one argument "
|
|
68 |
|
|
69 |
okAction2 := aBlock
|
|
70 |
!
|
|
71 |
|
|
72 |
okText2:aString
|
|
73 |
"set the text to be displayed in the 2nd ok-button"
|
0
|
74 |
|
197
|
75 |
aString ~= okButton2 label ifTrue:[
|
|
76 |
okButton2 label:aString.
|
|
77 |
okButton2 resize.
|
|
78 |
shown ifTrue:[self resize]
|
|
79 |
]
|
|
80 |
!
|
0
|
81 |
|
197
|
82 |
okText2:aString action2:aBlock
|
|
83 |
"set the text to be displayed in the 2nd ok-button,
|
|
84 |
and its action"
|
|
85 |
|
|
86 |
self okText2:aString.
|
|
87 |
okAction2 := aBlock
|
0
|
88 |
! !
|
|
89 |
|
|
90 |
!EnterBox2 methodsFor:'initialization'!
|
|
91 |
|
197
|
92 |
focusSequence
|
|
93 |
^ Array with:enterField with:abortButton with:okButton with:okButton2
|
|
94 |
!
|
|
95 |
|
0
|
96 |
initialize
|
|
97 |
super initialize.
|
|
98 |
|
59
|
99 |
"
|
|
100 |
add a second ok-button
|
|
101 |
"
|
|
102 |
okButton2 := Button okButtonIn:buttonPanel.
|
95
|
103 |
okButton2 model:self; change:#ok2Pressed.
|
|
104 |
|
59
|
105 |
"
|
77
|
106 |
the old (see superclass) ok-button is no longer a return-button
|
59
|
107 |
"
|
0
|
108 |
okButton isReturnButton:false.
|
48
|
109 |
|
0
|
110 |
enterField leaveAction:[:key | self ok2Pressed]
|
|
111 |
! !
|
|
112 |
|
8
|
113 |
!EnterBox2 methodsFor:'realization'!
|
|
114 |
|
|
115 |
positionOffset
|
|
116 |
"return the delta, by which the box should be displayed
|
|
117 |
from the mouse pointer. Value returned here makes
|
|
118 |
okButton appear under the cursor"
|
|
119 |
|
60
|
120 |
buttonPanel setChildPositionsIfChanged.
|
8
|
121 |
^ (okButton2 originRelativeTo:self) + (okButton2 extent // 2)
|
|
122 |
! !
|
|
123 |
|
0
|
124 |
!EnterBox2 methodsFor:'user interaction'!
|
|
125 |
|
77
|
126 |
keyPress:aKey x:x y:y
|
|
127 |
"return-key dublicates ok-function if acceptReturnAsOK is true"
|
|
128 |
|
|
129 |
acceptReturnAsOK ifTrue:[
|
|
130 |
(aKey == #Return) ifTrue:[^ self ok2Pressed]
|
|
131 |
].
|
|
132 |
super keyPress:aKey x:x y:y
|
197
|
133 |
!
|
|
134 |
|
|
135 |
ok2Pressed
|
|
136 |
"user pressed 2nd ok button - evaluate action"
|
|
137 |
|
|
138 |
okButton2 turnOffWithoutRedraw.
|
|
139 |
self hideAndEvaluate:okAction2
|
0
|
140 |
! !
|
197
|
141 |
|