author | Claus Gittinger <cg@exept.de> |
Thu, 15 Apr 1999 18:30:31 +0200 | |
changeset 1312 | 4c706bd30a5c |
parent 1281 | 94b22cb9c19f |
child 2108 | cbba33be6ac0 |
permissions | -rw-r--r-- |
332 | 1 |
" |
2 |
COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger |
|
679
bd0e422aab67
fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
3 |
All Rights Reserved |
332 | 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 |
||
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
14 |
ComboView subclass:#ComboBoxView |
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
15 |
instanceVariableNames:'' |
124 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'Views-Interactors' |
|
19 |
! |
|
20 |
||
275 | 21 |
!ComboBoxView class methodsFor:'documentation'! |
124 | 22 |
|
332 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger |
|
679
bd0e422aab67
fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
26 |
All Rights Reserved |
332 | 27 |
|
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
||
36 |
! |
|
37 |
||
124 | 38 |
documentation |
39 |
" |
|
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
40 |
A ComboBoxView combines an inputField with a drop down list of default inputs; |
126
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
41 |
choosing any from the pulled list presets the string in the field. |
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
42 |
|
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
43 |
In contrast to a PopUpList or ComboListView, the string can still be edited - |
126
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
44 |
the list is actually only a set of values for the convenience of the user. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
45 |
|
275 | 46 |
Not yet finished - it may need more protocol. |
47 |
||
48 |
[author:] |
|
1281 | 49 |
Claus Gittinger |
181 | 50 |
|
51 |
[see also:] |
|
1281 | 52 |
ComboView |
53 |
PopUpList SelectionInListView |
|
54 |
ComboListView ExtendedComboBox |
|
55 |
PullDownMenu Label EntryField |
|
124 | 56 |
" |
57 |
! |
|
58 |
||
59 |
examples |
|
60 |
" |
|
305 | 61 |
non MVC operation: |
679
bd0e422aab67
fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
62 |
[exBegin] |
124 | 63 |
|top b| |
64 |
||
65 |
top := StandardSystemView new. |
|
66 |
top extent:(300 @ 200). |
|
67 |
||
68 |
b := ComboBoxView in:top. |
|
69 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
70 |
b bottomInset:(b preferredExtent y negated). |
|
71 |
||
72 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
73 |
top open. |
|
679
bd0e422aab67
fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
74 |
[exEnd] |
124 | 75 |
|
76 |
||
77 |
||
305 | 78 |
with action: |
679
bd0e422aab67
fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
79 |
[exBegin] |
305 | 80 |
|top b| |
81 |
||
82 |
top := StandardSystemView new. |
|
83 |
top extent:(300 @ 200). |
|
84 |
||
85 |
b := ComboBoxView in:top. |
|
86 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
87 |
b bottomInset:(b preferredExtent y negated). |
|
88 |
||
89 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
90 |
b action:[:entry | Transcript showCR:entry]. |
|
91 |
top open. |
|
679
bd0e422aab67
fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
92 |
[exEnd] |
305 | 93 |
|
94 |
||
95 |
||
124 | 96 |
model operation: |
679
bd0e422aab67
fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
97 |
[exBegin] |
124 | 98 |
|model top b| |
99 |
||
100 |
model := 'foo' asValue. |
|
101 |
||
102 |
top := StandardSystemView new. |
|
103 |
top extent:(300 @ 200). |
|
104 |
||
105 |
b := ComboBoxView in:top. |
|
106 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
107 |
b bottomInset:(b preferredExtent y negated). |
|
108 |
||
109 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
110 |
b model:model. |
|
111 |
||
112 |
top openModal. |
|
184 | 113 |
Transcript showCR:('comboBox''s value: ' , model value). |
679
bd0e422aab67
fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
114 |
[exEnd] |
126
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
115 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
116 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
117 |
in a dialog: |
679
bd0e422aab67
fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
118 |
[exBegin] |
126
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
119 |
|model1 model2 dialog b| |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
120 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
121 |
model1 := 'foo' asValue. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
122 |
model2 := 'bar' asValue. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
123 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
124 |
dialog := Dialog new. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
125 |
(dialog addTextLabel:'ComboBox example:') adjust:#left. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
126 |
dialog addVerticalSpace. |
124 | 127 |
|
126
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
128 |
(b := dialog addComboBoxOn:model1 tabable:true). |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
129 |
b list:#('fee' 'foe' 'foo'). |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
130 |
dialog addVerticalSpace. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
131 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
132 |
(b := dialog addComboBoxOn:model2 tabable:true). |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
133 |
b list:#('bar' 'baz' 'baloo'). |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
134 |
dialog addVerticalSpace. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
135 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
136 |
dialog addOkButton. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
137 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
138 |
dialog open. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
139 |
|
184 | 140 |
Transcript showCR:('1st comboBox''s value: ' , model1 value). |
141 |
Transcript showCR:('2nd comboBox''s value: ' , model2 value). |
|
679
bd0e422aab67
fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
142 |
[exEnd] |
124 | 143 |
" |
144 |
! ! |
|
145 |
||
126
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
146 |
!ComboBoxView methodsFor:'accessing-components'! |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
147 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
148 |
editor |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
149 |
"return the inputField component" |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
150 |
|
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
151 |
^ field |
126
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
152 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
153 |
"Created: 9.2.1996 / 20:18:03 / cg" |
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
154 |
"Modified: 28.2.1996 / 15:10:50 / cg" |
124 | 155 |
! ! |
156 |
||
157 |
!ComboBoxView methodsFor:'accessing-mvc'! |
|
158 |
||
159 |
model |
|
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
160 |
^ field model |
124 | 161 |
|
162 |
"Created: 9.2.1996 / 00:50:18 / cg" |
|
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
163 |
"Modified: 28.2.1996 / 15:10:59 / cg" |
124 | 164 |
! |
165 |
||
166 |
model:aModel |
|
679
bd0e422aab67
fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
167 |
super model:aModel. |
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
168 |
field model:aModel. |
124 | 169 |
|
170 |
"Created: 9.2.1996 / 00:50:12 / cg" |
|
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
171 |
"Modified: 28.2.1996 / 15:11:03 / cg" |
124 | 172 |
! ! |
173 |
||
1312 | 174 |
!ComboBoxView methodsFor:'event handling'! |
175 |
||
176 |
hasKeyboardFocus:aBoolean |
|
177 |
super hasKeyboardFocus:aBoolean. |
|
178 |
field hasKeyboardFocus:aBoolean |
|
179 |
! |
|
180 |
||
181 |
showFocus:explicit |
|
182 |
super showFocus:explicit. |
|
183 |
field showCursor. |
|
184 |
||
185 |
! |
|
186 |
||
187 |
showNoFocus:explicit |
|
188 |
super showNoFocus:explicit. |
|
189 |
field hideCursor. |
|
190 |
||
191 |
! ! |
|
192 |
||
124 | 193 |
!ComboBoxView methodsFor:'initialization'! |
194 |
||
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
195 |
initializeField |
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
196 |
field := EditField in:self. |
519 | 197 |
field borderWidth:0. |
279 | 198 |
field model:(ValueHolder newString). |
305 | 199 |
field acceptOnLostFocus:true. |
200 |
field acceptOnLeave:true. |
|
201 |
field leaveAction:[:key | self fieldLeft]. |
|
124 | 202 |
|
203 |
" |
|
204 |
all of my input goes to the enterfield |
|
205 |
" |
|
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
206 |
self delegate:(KeyboardForwarder toView:field). |
124 | 207 |
|
208 |
" |
|
209 |
|b| |
|
210 |
||
211 |
b := ComboBoxView new. |
|
212 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
213 |
b open |
|
214 |
" |
|
215 |
||
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
216 |
"Created: 28.2.1996 / 15:07:51 / cg" |
305 | 217 |
"Modified: 26.2.1997 / 19:44:13 / cg" |
124 | 218 |
! ! |
219 |
||
1183
667132091c2f
ComboBox's inputField ought to use its default font.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
220 |
!ComboBoxView methodsFor:'private'! |
667132091c2f
ComboBox's inputField ought to use its default font.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
221 |
|
667132091c2f
ComboBox's inputField ought to use its default font.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
222 |
setFieldsFont:aFont |
667132091c2f
ComboBox's inputField ought to use its default font.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
223 |
"ignored - the inputFields font remains unchanged" |
667132091c2f
ComboBox's inputField ought to use its default font.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
224 |
! ! |
667132091c2f
ComboBox's inputField ought to use its default font.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
225 |
|
291 | 226 |
!ComboBoxView methodsFor:'queries'! |
227 |
||
228 |
specClass |
|
597 | 229 |
"XXX no longer needed (inherited default works here)" |
230 |
||
291 | 231 |
self class == ComboBoxView ifTrue:[ |
679
bd0e422aab67
fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
232 |
^ ComboBoxSpec |
291 | 233 |
]. |
301 | 234 |
^ super specClass |
235 |
||
597 | 236 |
"Modified: / 31.10.1997 / 19:49:39 / cg" |
291 | 237 |
! ! |
238 |
||
124 | 239 |
!ComboBoxView methodsFor:'user interaction'! |
240 |
||
311 | 241 |
fieldLeft |
242 |
field accept. |
|
243 |
||
244 |
action notNil ifTrue:[ |
|
679
bd0e422aab67
fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
245 |
action value:(field contents) |
311 | 246 |
]. |
247 |
||
248 |
"Modified: 26.2.1997 / 19:38:24 / cg" |
|
249 |
"Created: 26.2.1997 / 19:42:30 / cg" |
|
250 |
! |
|
251 |
||
252 |
select:index |
|
230 | 253 |
|what| |
254 |
||
255 |
what := list at:index. |
|
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
256 |
field contents:what. |
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
257 |
field accept. |
124 | 258 |
pullDownButton turnOff. |
259 |
||
305 | 260 |
action notNil ifTrue:[ |
679
bd0e422aab67
fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
261 |
action value:what |
305 | 262 |
]. |
263 |
||
264 |
"Modified: 26.2.1997 / 19:38:24 / cg" |
|
311 | 265 |
"Created: 28.2.1997 / 14:01:53 / cg" |
124 | 266 |
! ! |
267 |
||
275 | 268 |
!ComboBoxView class methodsFor:'documentation'! |
124 | 269 |
|
270 |
version |
|
1312 | 271 |
^ '$Header: /cvs/stx/stx/libwidg2/ComboBoxView.st,v 1.24 1999-04-15 16:30:31 cg Exp $' |
124 | 272 |
! ! |