author | Stefan Vogel <sv@exept.de> |
Fri, 18 Jul 2008 10:56:52 +0200 | |
changeset 3480 | 5178cda62a25 |
parent 3463 | 2f56e8ccb3f8 |
child 4165 | 042f65590cc8 |
permissions | -rw-r--r-- |
1302 | 1 |
" |
332 | 2 |
COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger |
1295 | 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 |
" |
|
1826 | 12 |
"{ Package: 'stx:libwidg2' }" |
13 |
||
131 | 14 |
ComboView subclass:#ComboListView |
3080 | 15 |
instanceVariableNames:'useIndex values selectCondition' |
1729 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'Views-Interactors' |
|
131 | 19 |
! |
20 |
||
270 | 21 |
!ComboListView class methodsFor:'documentation'! |
131 | 22 |
|
332 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger |
|
1295 | 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 |
! |
|
38 |
||
131 | 39 |
documentation |
40 |
" |
|
41 |
A ComboListView combines an label with a drop down list of default inputs; |
|
42 |
choosing any from the pulled list sets the string in the label. |
|
43 |
||
44 |
This is the same as a PopUpList or SelectionInListView, bit looks different. |
|
45 |
||
310 | 46 |
The preferred model is a SelectionInList, but a simple valueHolder |
47 |
may also be used. |
|
48 |
If some other model is to be used, the changeMessage and aspectMessage |
|
49 |
should be defined as appropriate (or an aspectAdaptor should be used). |
|
50 |
If a listHolder is set, that one is assumed to provide the list of |
|
51 |
items in the popped menu; |
|
52 |
otherwise, if listMessage is nonNil, the model is assumed to also provide the |
|
53 |
list as displayed in the popped menu. |
|
275 | 54 |
|
55 |
[author:] |
|
1281 | 56 |
Claus Gittinger |
275 | 57 |
|
58 |
[see also:] |
|
1281 | 59 |
ComboView |
60 |
PopUpList SelectionInListView |
|
61 |
ComboBoxView ExtendedComboBox |
|
62 |
PullDownMenu Label EntryField |
|
131 | 63 |
" |
64 |
! |
|
65 |
||
66 |
examples |
|
67 |
" |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
68 |
non-MVC use; |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
69 |
set the list explicitely: |
1826 | 70 |
[exBegin] |
682 | 71 |
|top comboList| |
72 |
||
73 |
top := StandardSystemView new. |
|
74 |
top extent:(300 @ 200). |
|
75 |
||
76 |
comboList := ComboListView in:top. |
|
77 |
comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
78 |
comboList bottomInset:(comboList preferredExtent y negated). |
|
79 |
||
80 |
comboList list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
81 |
top open. |
|
82 |
[exEnd] |
|
83 |
||
2825 | 84 |
a really, really long list (notice scrollup/down buttons at the top/bottom); |
85 |
[exBegin] |
|
86 |
|top comboList| |
|
87 |
||
88 |
top := StandardSystemView new. |
|
89 |
top extent:(300 @ 200). |
|
90 |
||
91 |
comboList := ComboListView in:top. |
|
92 |
comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
93 |
comboList bottomInset:(comboList preferredExtent y negated). |
|
94 |
||
95 |
comboList list:((1 to:100) collect:[:n | n printString]). |
|
96 |
top open. |
|
97 |
[exEnd] |
|
682 | 98 |
|
99 |
||
100 |
with callBack: |
|
101 |
[exBegin] |
|
102 |
|top comboList| |
|
131 | 103 |
|
104 |
top := StandardSystemView new. |
|
105 |
top extent:(300 @ 200). |
|
106 |
||
682 | 107 |
comboList := ComboListView in:top. |
108 |
comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
109 |
comboList bottomInset:(comboList preferredExtent y negated). |
|
131 | 110 |
|
682 | 111 |
comboList list:#('hello' 'world' 'this' 'is' 'st/x'). |
112 |
comboList action:[:selected | Transcript showCR:selected]. |
|
131 | 113 |
top open. |
682 | 114 |
[exEnd] |
131 | 115 |
|
116 |
||
117 |
||
682 | 118 |
with separating lines: |
119 |
[exBegin] |
|
120 |
|top comboList| |
|
305 | 121 |
|
682 | 122 |
top := StandardSystemView label:'fruit chooser'. |
305 | 123 |
top extent:(300 @ 200). |
124 |
||
682 | 125 |
comboList := ComboListView in:top. |
126 |
comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
127 |
comboList bottomInset:(comboList preferredExtent y negated). |
|
305 | 128 |
|
682 | 129 |
comboList label:'fruit'. |
130 |
comboList list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas'). |
|
131 |
comboList action:[:selected | Transcript showCR:selected]. |
|
132 |
top open |
|
133 |
[exEnd] |
|
134 |
||
305 | 135 |
|
136 |
||
137 |
||
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
138 |
with values different from the label strings: |
682 | 139 |
[exBegin] |
140 |
|top comboList| |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
141 |
|
682 | 142 |
top := StandardSystemView label:'fruit chooser'. |
143 |
top extent:(300 @ 200). |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
144 |
|
682 | 145 |
comboList := ComboListView in:top. |
146 |
comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
147 |
comboList bottomInset:(comboList preferredExtent y negated). |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
148 |
|
682 | 149 |
comboList label:'dummy'. |
150 |
comboList list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas'). |
|
151 |
comboList selection:'apples'. |
|
152 |
comboList values:#(10 20 30 40 nil 50). |
|
153 |
comboList action:[:what | Transcript show:'you selected: '; showCR:what]. |
|
154 |
top open |
|
155 |
[exEnd] |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
156 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
157 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
158 |
sometimes, you may like the index instead of the value: |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
159 |
(notice, that the separating line counts, so you have to take care ...) |
682 | 160 |
[exBegin] |
161 |
|top comboList| |
|
162 |
||
163 |
top := StandardSystemView label:'fruit chooser'. |
|
164 |
top extent:(300 @ 200). |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
165 |
|
682 | 166 |
comboList := ComboListView in:top. |
167 |
comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
168 |
comboList bottomInset:(comboList preferredExtent y negated). |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
169 |
|
682 | 170 |
comboList label:'dummy'. |
171 |
comboList list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas'). |
|
172 |
comboList selection:'apples'. |
|
173 |
comboList action:[:what | Transcript show:'you selected: '; showCR:what]. |
|
174 |
comboList useIndex:true. |
|
175 |
top open |
|
176 |
[exEnd] |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
177 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
178 |
since the list is actually represented by a menuView, |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
179 |
which itself is inheriting from listView, which itself can display |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
180 |
things different from strings, arbitrary lists can be constructed: |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
181 |
(see ListEntry, LabelAndIcon and Text classes) |
682 | 182 |
[exBegin] |
183 |
|top comboList l| |
|
184 |
||
185 |
top := StandardSystemView label:'fruit chooser'. |
|
186 |
top extent:(300 @ 200). |
|
187 |
||
188 |
comboList := ComboListView in:top. |
|
189 |
comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
190 |
comboList bottomInset:(comboList preferredExtent y negated). |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
191 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
192 |
l := OrderedCollection new. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
193 |
l add:(Text string:'apples' color:Color red). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
194 |
l add:(Text string:'bananas' color:Color red). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
195 |
l add:(Text string:'grape' color:Color red). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
196 |
l add:(Text string:'lemon' color:Color red). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
197 |
l add:'='. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
198 |
l add:(Text string:'margaritas' color:Color green darkened darkened). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
199 |
l add:(Text string:'pina colada' color:Color green darkened darkened). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
200 |
l add:'='. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
201 |
l add:(Text string:'smalltalk' color:Color blue). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
202 |
l add:(Text string:'c++' color:Color blue). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
203 |
l add:(Text string:'eiffel' color:Color blue). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
204 |
l add:(Text string:'java' color:Color blue). |
682 | 205 |
comboList list:l. |
206 |
comboList values:#(apples bananas grape lemon |
|
207 |
nil |
|
208 |
'mhmh - so good' 'makes headache' |
|
209 |
nil |
|
210 |
'great' 'another headache' 'not bad' 'neat'). |
|
211 |
comboList selection:'apples'. |
|
212 |
comboList action:[:what | Transcript show:'you selected: '; showCR:what]. |
|
213 |
top open |
|
214 |
[exEnd] |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
215 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
216 |
with values different from the label strings: |
682 | 217 |
[exBegin] |
218 |
|top comboList| |
|
219 |
||
220 |
top := StandardSystemView label:'language chooser'. |
|
221 |
top extent:(300 @ 200). |
|
222 |
||
223 |
comboList := ComboListView in:top. |
|
224 |
comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
225 |
|
682 | 226 |
comboList list:( #( |
227 |
'usa' |
|
228 |
'uk' |
|
229 |
'france' |
|
230 |
'germany' |
|
231 |
'italy' |
|
232 |
) collect:[:country | |
|
233 |
LabelAndIcon |
|
234 |
icon:(Image fromFile:'bitmaps/xpmBitmaps/countries/' , country , '.xpm') |
|
235 |
string:country |
|
236 |
] |
|
237 |
). |
|
238 |
comboList values:#(us england france germany italy). |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
239 |
|
682 | 240 |
comboList action:[:what | Transcript show:'you selected: '; showCR:what]. |
241 |
comboList bottomInset:(comboList preferredExtent y negated). |
|
242 |
top open |
|
243 |
[exEnd] |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
244 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
245 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
246 |
with a model (see in the inspector, how the index-holders value changes) |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
247 |
the defaults are setup to allow a SelectionInList directly as model: |
682 | 248 |
[exBegin] |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
249 |
|p model| |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
250 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
251 |
model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
252 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
253 |
p := ComboListView label:'healthy fruit'. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
254 |
p model:model. |
682 | 255 |
p openAt:(Screen current center). |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
256 |
model inspect |
682 | 257 |
[exEnd] |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
258 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
259 |
model provides selection; list is explicit: |
682 | 260 |
[exBegin] |
131 | 261 |
|model top b| |
262 |
||
263 |
model := 'foo' asValue. |
|
264 |
||
265 |
top := StandardSystemView new. |
|
266 |
top extent:(300 @ 200). |
|
267 |
||
268 |
b := ComboListView in:top. |
|
269 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
270 |
b bottomInset:(b preferredExtent y negated). |
|
271 |
||
272 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
310 | 273 |
b model:model. |
131 | 274 |
|
275 |
top openModal. |
|
184 | 276 |
Transcript showCR:('comboBox''s value: ' , model value). |
682 | 277 |
[exEnd] |
131 | 278 |
|
279 |
||
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
280 |
a comboListView and a SelectionInListView on the same model: |
682 | 281 |
[exBegin] |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
282 |
|p slv model| |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
283 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
284 |
model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
285 |
model selection:'apples'. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
286 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
287 |
p := ComboListView on:model. |
682 | 288 |
p openAt:(Screen current center). |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
289 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
290 |
slv := SelectionInListView on:model. |
682 | 291 |
slv openAt:(Screen current center + (100@100)). |
292 |
[exEnd] |
|
293 |
||
294 |
||
295 |
like above, using index: |
|
296 |
[exBegin] |
|
297 |
|p slv model| |
|
298 |
||
299 |
model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
300 |
model selection:'apples'. |
|
301 |
||
302 |
p := ComboListView on:model. |
|
303 |
p openAt:(Screen current center). |
|
304 |
||
305 |
slv := SelectionInListView on:model. |
|
306 |
slv openAt:(Screen current center + (100@100)). |
|
307 |
[exEnd] |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
308 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
309 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
310 |
two comboListViews on the same model, different aspects: |
682 | 311 |
[exBegin] |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
312 |
|top panel p model| |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
313 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
314 |
model := Plug new. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
315 |
model respondTo:#eat: with:[:val | Transcript showCR:'eat: ' , val]. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
316 |
model respondTo:#drink: with:[:val | Transcript showCR:'drink: ' , val]. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
317 |
model respondTo:#meals with:[#(taco burrito enchilada)]. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
318 |
model respondTo:#drinks with:[#(margarita water corona)]. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
319 |
|
682 | 320 |
top := StandardSystemView label:'meal chooser'. |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
321 |
top extent:(150@150). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
322 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
323 |
panel horizontalLayout:#fitSpace. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
324 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
325 |
p := ComboListView label:'meals'. |
682 | 326 |
p aspect:nil; model:model; listMessage:#meals; change:#eat:. |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
327 |
panel add:p. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
328 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
329 |
p := ComboListView label:'drinks'. |
682 | 330 |
p aspect:nil; model:model; listMessage:#drinks; change:#drink:. |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
331 |
panel add:p. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
332 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
333 |
top open |
682 | 334 |
[exEnd] |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
335 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
336 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
337 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
338 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
339 |
with separate list- and indexHolders: |
682 | 340 |
[exBegin] |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
341 |
|p selectionHolder listHolder| |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
342 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
343 |
listHolder := #('apples' 'bananas' 'grape' 'lemon' 'margaritas') asValue. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
344 |
selectionHolder := 'apples' asValue. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
345 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
346 |
p := ComboListView label:'healthy fruit'. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
347 |
p listHolder:listHolder. |
310 | 348 |
p model:selectionHolder. |
682 | 349 |
p openAt:(Screen current center). |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
350 |
selectionHolder inspect |
682 | 351 |
[exEnd] |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
352 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
353 |
using different values: |
682 | 354 |
[exBegin] |
355 |
|p priceHolder listHolder prices priceField| |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
356 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
357 |
listHolder := #('apples' 'bananas' 'grape' 'lemon' 'margaritas') asValue. |
682 | 358 |
prices := #(10 10 5 15 50). |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
359 |
|
682 | 360 |
priceHolder := nil asValue. |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
361 |
|
682 | 362 |
p := ComboListView new. |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
363 |
p listHolder:listHolder. |
682 | 364 |
p model:priceHolder. |
365 |
p values:prices. |
|
366 |
p openAt:(Screen current center). |
|
367 |
||
368 |
priceField := EditField new. |
|
369 |
priceField readOnly:true. |
|
370 |
priceField model:(TypeConverter onNumberValue:priceHolder). |
|
371 |
priceField openAt:(Screen current center + (10@10)). |
|
372 |
[exEnd] |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
373 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
374 |
|
131 | 375 |
in a dialog: |
682 | 376 |
[exBegin] |
131 | 377 |
|model1 model2 dialog b| |
378 |
||
379 |
model1 := 'foo' asValue. |
|
380 |
model2 := 'bar' asValue. |
|
381 |
||
382 |
dialog := Dialog new. |
|
383 |
(dialog addTextLabel:'ComboList example:') adjust:#left. |
|
384 |
dialog addVerticalSpace. |
|
385 |
||
386 |
(b := dialog addComboListOn:model1 tabable:true). |
|
387 |
b list:#('fee' 'foe' 'foo'). |
|
388 |
dialog addVerticalSpace. |
|
389 |
||
390 |
(b := dialog addComboListOn:model2 tabable:true). |
|
391 |
b list:#('bar' 'baz' 'baloo'). |
|
392 |
dialog addVerticalSpace. |
|
393 |
||
394 |
dialog addOkButton. |
|
395 |
||
396 |
dialog open. |
|
397 |
||
184 | 398 |
Transcript showCR:('1st comboBox''s value: ' , model1 value). |
399 |
Transcript showCR:('2nd comboBox''s value: ' , model2 value). |
|
682 | 400 |
[exEnd] |
3080 | 401 |
|
402 |
Select condition |
|
403 |
[exBegin] |
|
404 |
|top comboList| |
|
405 |
||
406 |
top := StandardSystemView new. |
|
407 |
top extent:(300 @ 200). |
|
408 |
||
409 |
comboList := ComboListView in:top. |
|
410 |
comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
411 |
comboList bottomInset:(comboList preferredExtent y negated). |
|
412 |
||
413 |
comboList list:((1 to:100) collect:[:n | n printString]). |
|
414 |
comboList selectCondition:[:newValue | (Number readFrom:newValue) even]. |
|
415 |
top open. |
|
416 |
[exEnd] |
|
417 |
||
418 |
||
419 |
||
131 | 420 |
" |
421 |
! ! |
|
422 |
||
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
423 |
!ComboListView class methodsFor:'defaults'! |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
424 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
425 |
defaultAspectMessage |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
426 |
^ #selection |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
427 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
428 |
"Created: 27.2.1997 / 15:23:13 / cg" |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
429 |
! |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
430 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
431 |
defaultChangeMessage |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
432 |
^ #selection: |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
433 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
434 |
"Created: 27.2.1997 / 15:23:18 / cg" |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
435 |
! ! |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
436 |
|
3080 | 437 |
!ComboListView methodsFor:'accessing'! |
438 |
||
439 |
selectCondition:something |
|
440 |
selectCondition := something. |
|
441 |
! ! |
|
442 |
||
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
443 |
!ComboListView methodsFor:'accessing-behavior'! |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
444 |
|
501 | 445 |
useIndex |
446 |
"specify, if the selected components value or its index in the |
|
447 |
list should be sent to the model. The default is its value." |
|
448 |
||
449 |
^ useIndex |
|
450 |
! |
|
451 |
||
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
452 |
useIndex:aBoolean |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
453 |
"specify, if the selected components value or its index in the |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
454 |
list should be sent to the model. The default is its value." |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
455 |
|
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
456 |
useIndex := aBoolean. |
682 | 457 |
|
684 | 458 |
"/ "/ change the aspectMessage - but only if it has not yet been |
459 |
"/ "/ changed explicitly |
|
460 |
"/ useIndex ifTrue:[ |
|
461 |
"/ changeMsg == #selection: ifTrue:[ |
|
462 |
"/ changeMsg := #selectionIndex:. |
|
463 |
"/ aspectMsg := #selectionIndex. |
|
464 |
"/ ] |
|
465 |
"/ ] ifFalse:[ |
|
466 |
"/ changeMsg == #selectionIndex: ifTrue:[ |
|
467 |
"/ changeMsg := #selection:. |
|
468 |
"/ aspectMsg := #selection. |
|
469 |
"/ ] |
|
470 |
"/ ]. |
|
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
471 |
|
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
472 |
"Created: 26.7.1996 / 17:44:18 / cg" |
679
bd0e422aab67
fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
473 |
"Modified: / 24.1.1998 / 19:06:41 / cg" |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
474 |
! |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
475 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
476 |
values:aCollection |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
477 |
"specify, which values are to be stuffed into the model or |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
478 |
passed via the actionBlock." |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
479 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
480 |
values := aCollection. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
481 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
482 |
"Created: 27.2.1997 / 15:10:12 / cg" |
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
483 |
! ! |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
484 |
|
131 | 485 |
!ComboListView methodsFor:'accessing-components'! |
486 |
||
487 |
label |
|
181 | 488 |
"return the label component" |
131 | 489 |
|
490 |
^ field |
|
491 |
||
492 |
"Modified: 28.2.1996 / 15:10:50 / cg" |
|
493 |
"Created: 28.2.1996 / 15:13:51 / cg" |
|
494 |
! ! |
|
495 |
||
215 | 496 |
!ComboListView methodsFor:'accessing-contents'! |
497 |
||
536 | 498 |
contents |
499 |
"get the current value - either in the fields model |
|
500 |
or directly" |
|
501 |
||
502 |
|m| |
|
503 |
||
504 |
(m := field model) notNil ifTrue:[ |
|
1295 | 505 |
^ m value |
536 | 506 |
] ifFalse:[ |
1295 | 507 |
^ field label |
536 | 508 |
] |
509 |
! |
|
510 |
||
215 | 511 |
contents:something |
2876 | 512 |
"set the current value - either in the fields model or directly" |
272 | 513 |
|
215 | 514 |
|m| |
515 |
||
516 |
(m := field model) notNil ifTrue:[ |
|
1295 | 517 |
m value:something |
215 | 518 |
] ifFalse:[ |
1295 | 519 |
field label:something |
215 | 520 |
] |
521 |
||
522 |
"Created: 15.7.1996 / 13:16:49 / cg" |
|
272 | 523 |
"Modified: 5.1.1997 / 00:05:04 / cg" |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
524 |
! |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
525 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
526 |
selection:something |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
527 |
"set the contents of my field; questionable" |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
528 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
529 |
self contents:something |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
530 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
531 |
"Created: 27.2.1997 / 15:07:37 / cg" |
215 | 532 |
! ! |
533 |
||
3368
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
534 |
!ComboListView methodsFor:'event handling'! |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
535 |
|
3463 | 536 |
enableStateChanged |
537 |
|fieldBG| |
|
538 |
||
539 |
super enableStateChanged. |
|
540 |
self enabled ifTrue:[ |
|
541 |
fieldBG := (styleSheet colorAt:#'comboList.backgroundColor' default:Color white). |
|
542 |
] ifFalse:[ |
|
543 |
fieldBG := View defaultViewBackgroundColor. |
|
544 |
]. |
|
545 |
field backgroundColor:fieldBG. |
|
546 |
! |
|
547 |
||
3368
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
548 |
keyPress:key x:x y:y |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
549 |
"select by first letter" |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
550 |
|
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
551 |
|idx searchKey startIndex| |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
552 |
|
3451 | 553 |
list notEmptyOrNil ifTrue:[ |
554 |
key == #CursorDown ifTrue:[ |
|
555 |
self deltaSelect:1. |
|
556 |
^ self. |
|
557 |
]. |
|
558 |
key == #CursorUp ifTrue:[ |
|
559 |
self deltaSelect:-1. |
|
560 |
^ self. |
|
561 |
]. |
|
3368
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
562 |
|
3451 | 563 |
currentIndex isNil ifTrue:[ |
564 |
currentIndex := 1. |
|
565 |
]. |
|
566 |
searchKey := key asLowercase. |
|
567 |
startIndex := currentIndex + 1. |
|
568 |
[ |
|
569 |
idx := list findFirst:[:eachEntry| (eachEntry printString at:1 ifAbsent:Character cr) asLowercase = searchKey] |
|
570 |
startingAt:startIndex. |
|
571 |
] doWhile:[ idx = 0 and:[startIndex ~= 1 and:[startIndex := 1. true]] ]. |
|
3368
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
572 |
|
3451 | 573 |
idx = 0 ifFalse:[ |
574 |
self select:idx. |
|
575 |
^ self. |
|
576 |
]. |
|
3368
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
577 |
]. |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
578 |
|
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
579 |
^ super keyPress:key x:x y:y |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
580 |
! ! |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
581 |
|
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
582 |
!ComboListView methodsFor:'focus handling'! |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
583 |
|
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
584 |
showFocus:explicit |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
585 |
"the button got the keyboard focus |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
586 |
(either explicit, via tabbing; or implicit, by pointer movement) |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
587 |
- change any display attributes as req'd." |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
588 |
|
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
589 |
(styleSheet at:#'focusHighlightStyle') == #win95 ifTrue:[ |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
590 |
field hasFocus:true. |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
591 |
field invalidate. |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
592 |
] ifFalse:[ |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
593 |
^ super showFocus:explicit |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
594 |
] |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
595 |
! |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
596 |
|
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
597 |
showNoFocus:explicit |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
598 |
"the button lost the keyboard focus |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
599 |
(either explicit, via tabbing; or implicit, by pointer movement) |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
600 |
- change any display attributes as req'd." |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
601 |
|
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
602 |
(styleSheet at:#'focusHighlightStyle') == #win95 ifTrue:[ |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
603 |
field hasFocus:false. |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
604 |
field invalidate. |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
605 |
] ifFalse:[ |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
606 |
^ super showNoFocus:explicit |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
607 |
] |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
608 |
! |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
609 |
|
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
610 |
subviewsInFocusOrder |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
611 |
"none of my subviews should get he focus" |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
612 |
|
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
613 |
^ #() |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
614 |
! |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
615 |
|
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
616 |
wantsFocusWithButtonPress |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
617 |
"we want the focus, in order to do selection via mouse wheel" |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
618 |
|
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
619 |
^ true |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
620 |
! ! |
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
621 |
|
131 | 622 |
!ComboListView methodsFor:'initialization'! |
623 |
||
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
624 |
initialize |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
625 |
useIndex isNil ifTrue:[useIndex := false]. |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
626 |
|
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
627 |
super initialize. |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
628 |
|
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
629 |
"Created: 26.7.1996 / 17:44:57 / cg" |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
630 |
"Modified: 27.2.1997 / 15:23:24 / cg" |
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
631 |
! |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
632 |
|
131 | 633 |
initializeField |
3368
64e841a58dd1
Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents:
3314
diff
changeset
|
634 |
field := CheckLabel in:self. |
519 | 635 |
field level:-1; borderWidth:0. |
131 | 636 |
field adjust:#left. |
3314 | 637 |
field delegate:self. "delegate mouseWheel events to myself" |
3463 | 638 |
field backgroundColor:(styleSheet colorAt:#'comboList.backgroundColor' default:Color white). |
3480 | 639 |
field font:font. |
131 | 640 |
|
641 |
" |
|
642 |
|b| |
|
643 |
||
644 |
b := ComboListView new. |
|
645 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
646 |
b open |
|
647 |
" |
|
648 |
||
649 |
"Created: 28.2.1996 / 15:13:46 / cg" |
|
650 |
"Modified: 28.2.1996 / 15:18:40 / cg" |
|
651 |
! ! |
|
652 |
||
3080 | 653 |
!ComboListView methodsFor:'menu interaction'! |
654 |
||
655 |
select:anIndex |
|
656 |
"sent from the popped menu, when an item was selected" |
|
657 |
||
658 |
|label value chg| |
|
659 |
||
660 |
values isNil ifTrue:[ |
|
661 |
value := anIndex. |
|
662 |
useIndex ifFalse:[ |
|
663 |
value := list at:anIndex. |
|
664 |
] |
|
665 |
] ifFalse:[ |
|
666 |
value := values at:anIndex |
|
667 |
]. |
|
668 |
||
669 |
selectCondition notNil ifTrue:[ |
|
670 |
(selectCondition value:value) ifFalse:[ |
|
671 |
^ self. |
|
672 |
] |
|
673 |
]. |
|
674 |
||
675 |
label := list at:anIndex. |
|
3314 | 676 |
currentIndex := anIndex. |
3080 | 677 |
|
678 |
field label:label. |
|
679 |
||
680 |
" |
|
681 |
ST-80 style model notification ... |
|
682 |
this updates the model (typically, a ValueHolder) |
|
683 |
" |
|
684 |
(model notNil and:[changeMsg notNil]) ifTrue:[ |
|
685 |
"/ kludge - try #value: if changeMsg is the default and |
|
686 |
"/ not understood by the model |
|
687 |
"/ this allows a valueHolder to be used, even |
|
688 |
"/ if the aspectMessage was not setup correctly. |
|
689 |
||
690 |
chg := changeMsg. |
|
691 |
chg == self class defaultChangeMessage ifTrue:[ |
|
692 |
(model respondsTo:chg) ifFalse:[ |
|
693 |
chg := #value: |
|
694 |
] |
|
695 |
]. |
|
696 |
||
697 |
self sendChangeMessage:chg with:value |
|
698 |
]. |
|
699 |
pullDownButton turnOff. |
|
700 |
||
701 |
" |
|
702 |
ST/X style actionBlock evaluation ... |
|
703 |
" |
|
704 |
action notNil ifTrue:[ |
|
705 |
action value:value |
|
706 |
]. |
|
707 |
||
708 |
"Created: / 27-02-1997 / 15:18:44 / cg" |
|
709 |
"Modified: / 28-02-1997 / 13:50:17 / cg" |
|
710 |
"Modified: / 15-09-2006 / 11:40:00 / User" |
|
711 |
! ! |
|
712 |
||
215 | 713 |
!ComboListView methodsFor:'private'! |
714 |
||
715 |
getValueFromModel |
|
1206 | 716 |
|selection idx aspect newContents| |
278 | 717 |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
718 |
(model notNil and:[aspectMsg notNil]) ifTrue:[ |
682 | 719 |
"/ kludge - try #value if aspect is the default and |
720 |
"/ not understood by the model |
|
721 |
"/ this allows a valueHolder to be used, even |
|
722 |
"/ if the aspectMessage was not setup correctly. |
|
309
f2ae122f6dad
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
307
diff
changeset
|
723 |
|
682 | 724 |
aspect := aspectMsg. |
725 |
aspect == self class defaultAspectMessage ifTrue:[ |
|
726 |
(model respondsTo:aspect) ifFalse:[ |
|
727 |
aspect := #value |
|
728 |
] |
|
729 |
]. |
|
730 |
||
1729 | 731 |
aspect == #value ifTrue:[ |
732 |
selection := model value |
|
733 |
] ifFalse:[ |
|
734 |
selection := model perform:aspect. |
|
735 |
]. |
|
309
f2ae122f6dad
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
307
diff
changeset
|
736 |
|
682 | 737 |
selection notNil ifTrue:[ |
738 |
values notNil ifTrue:[ |
|
739 |
idx := values indexOf:selection |
|
740 |
] ifFalse:[ |
|
741 |
useIndex ifTrue:[ |
|
742 |
idx := selection |
|
743 |
] ifFalse:[ |
|
744 |
self contents:selection. |
|
745 |
^ self. |
|
746 |
] |
|
747 |
]. |
|
2941
51cafd3a8877
avoid error accessing a nil-list
Claus Gittinger <cg@exept.de>
parents:
2876
diff
changeset
|
748 |
list notNil ifTrue:[ |
51cafd3a8877
avoid error accessing a nil-list
Claus Gittinger <cg@exept.de>
parents:
2876
diff
changeset
|
749 |
newContents := list at:idx ifAbsent:nil. |
51cafd3a8877
avoid error accessing a nil-list
Claus Gittinger <cg@exept.de>
parents:
2876
diff
changeset
|
750 |
] |
1206 | 751 |
]. |
752 |
self contents:newContents |
|
215 | 753 |
]. |
754 |
||
1729 | 755 |
"Created: / 15.7.1996 / 12:28:53 / cg" |
756 |
"Modified: / 1.3.2000 / 15:20:24 / cg" |
|
215 | 757 |
! ! |
758 |
||
291 | 759 |
!ComboListView methodsFor:'queries'! |
760 |
||
761 |
specClass |
|
598 | 762 |
"XXX no longer needed (inherited default works here)" |
763 |
||
291 | 764 |
self class == ComboListView ifTrue:[ |
1295 | 765 |
^ ComboListSpec |
291 | 766 |
]. |
301 | 767 |
^ super specClass |
291 | 768 |
|
598 | 769 |
"Modified: / 31.10.1997 / 19:49:34 / cg" |
291 | 770 |
! ! |
771 |
||
270 | 772 |
!ComboListView class methodsFor:'documentation'! |
131 | 773 |
|
774 |
version |
|
3480 | 775 |
^ '$Header: /cvs/stx/stx/libwidg2/ComboListView.st,v 1.47 2008-07-18 08:56:52 stefan Exp $' |
131 | 776 |
! ! |