author | Claus Gittinger <cg@exept.de> |
Tue, 07 Jun 2005 17:01:59 +0200 | |
changeset 2825 | b27f9e7776d7 |
parent 1826 | 080df5e45c3c |
child 2876 | dbeee558e9e7 |
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 |
" |
|
12 |
||
13 |
||
14 |
||
1826 | 15 |
"{ Package: 'stx:libwidg2' }" |
16 |
||
131 | 17 |
ComboView subclass:#ComboListView |
1729 | 18 |
instanceVariableNames:'useIndex values' |
19 |
classVariableNames:'' |
|
20 |
poolDictionaries:'' |
|
21 |
category:'Views-Interactors' |
|
131 | 22 |
! |
23 |
||
270 | 24 |
!ComboListView class methodsFor:'documentation'! |
131 | 25 |
|
332 | 26 |
copyright |
27 |
" |
|
28 |
COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger |
|
1295 | 29 |
All Rights Reserved |
332 | 30 |
|
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
||
39 |
||
40 |
! |
|
41 |
||
131 | 42 |
documentation |
43 |
" |
|
44 |
A ComboListView combines an label with a drop down list of default inputs; |
|
45 |
choosing any from the pulled list sets the string in the label. |
|
46 |
||
47 |
This is the same as a PopUpList or SelectionInListView, bit looks different. |
|
48 |
||
310 | 49 |
The preferred model is a SelectionInList, but a simple valueHolder |
50 |
may also be used. |
|
51 |
If some other model is to be used, the changeMessage and aspectMessage |
|
52 |
should be defined as appropriate (or an aspectAdaptor should be used). |
|
53 |
If a listHolder is set, that one is assumed to provide the list of |
|
54 |
items in the popped menu; |
|
55 |
otherwise, if listMessage is nonNil, the model is assumed to also provide the |
|
56 |
list as displayed in the popped menu. |
|
275 | 57 |
|
58 |
[author:] |
|
1281 | 59 |
Claus Gittinger |
275 | 60 |
|
61 |
[see also:] |
|
1281 | 62 |
ComboView |
63 |
PopUpList SelectionInListView |
|
64 |
ComboBoxView ExtendedComboBox |
|
65 |
PullDownMenu Label EntryField |
|
131 | 66 |
" |
67 |
! |
|
68 |
||
69 |
examples |
|
70 |
" |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
71 |
non-MVC use; |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
72 |
set the list explicitely: |
1826 | 73 |
[exBegin] |
682 | 74 |
|top comboList| |
75 |
||
76 |
top := StandardSystemView new. |
|
77 |
top extent:(300 @ 200). |
|
78 |
||
79 |
comboList := ComboListView in:top. |
|
80 |
comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
81 |
comboList bottomInset:(comboList preferredExtent y negated). |
|
82 |
||
83 |
comboList list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
84 |
top open. |
|
85 |
[exEnd] |
|
86 |
||
2825 | 87 |
a really, really long list (notice scrollup/down buttons at the top/bottom); |
88 |
[exBegin] |
|
89 |
|top comboList| |
|
90 |
||
91 |
top := StandardSystemView new. |
|
92 |
top extent:(300 @ 200). |
|
93 |
||
94 |
comboList := ComboListView in:top. |
|
95 |
comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
96 |
comboList bottomInset:(comboList preferredExtent y negated). |
|
97 |
||
98 |
comboList list:((1 to:100) collect:[:n | n printString]). |
|
99 |
top open. |
|
100 |
[exEnd] |
|
682 | 101 |
|
102 |
||
103 |
with callBack: |
|
104 |
[exBegin] |
|
105 |
|top comboList| |
|
131 | 106 |
|
107 |
top := StandardSystemView new. |
|
108 |
top extent:(300 @ 200). |
|
109 |
||
682 | 110 |
comboList := ComboListView in:top. |
111 |
comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
112 |
comboList bottomInset:(comboList preferredExtent y negated). |
|
131 | 113 |
|
682 | 114 |
comboList list:#('hello' 'world' 'this' 'is' 'st/x'). |
115 |
comboList action:[:selected | Transcript showCR:selected]. |
|
131 | 116 |
top open. |
682 | 117 |
[exEnd] |
131 | 118 |
|
119 |
||
120 |
||
682 | 121 |
with separating lines: |
122 |
[exBegin] |
|
123 |
|top comboList| |
|
305 | 124 |
|
682 | 125 |
top := StandardSystemView label:'fruit chooser'. |
305 | 126 |
top extent:(300 @ 200). |
127 |
||
682 | 128 |
comboList := ComboListView in:top. |
129 |
comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
130 |
comboList bottomInset:(comboList preferredExtent y negated). |
|
305 | 131 |
|
682 | 132 |
comboList label:'fruit'. |
133 |
comboList list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas'). |
|
134 |
comboList action:[:selected | Transcript showCR:selected]. |
|
135 |
top open |
|
136 |
[exEnd] |
|
137 |
||
305 | 138 |
|
139 |
||
140 |
||
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
141 |
with values different from the label strings: |
682 | 142 |
[exBegin] |
143 |
|top comboList| |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
144 |
|
682 | 145 |
top := StandardSystemView label:'fruit chooser'. |
146 |
top extent:(300 @ 200). |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
147 |
|
682 | 148 |
comboList := ComboListView in:top. |
149 |
comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
150 |
comboList bottomInset:(comboList preferredExtent y negated). |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
151 |
|
682 | 152 |
comboList label:'dummy'. |
153 |
comboList list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas'). |
|
154 |
comboList selection:'apples'. |
|
155 |
comboList values:#(10 20 30 40 nil 50). |
|
156 |
comboList action:[:what | Transcript show:'you selected: '; showCR:what]. |
|
157 |
top open |
|
158 |
[exEnd] |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
159 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
160 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
161 |
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
|
162 |
(notice, that the separating line counts, so you have to take care ...) |
682 | 163 |
[exBegin] |
164 |
|top comboList| |
|
165 |
||
166 |
top := StandardSystemView label:'fruit chooser'. |
|
167 |
top extent:(300 @ 200). |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
168 |
|
682 | 169 |
comboList := ComboListView in:top. |
170 |
comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
171 |
comboList bottomInset:(comboList preferredExtent y negated). |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
172 |
|
682 | 173 |
comboList label:'dummy'. |
174 |
comboList list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas'). |
|
175 |
comboList selection:'apples'. |
|
176 |
comboList action:[:what | Transcript show:'you selected: '; showCR:what]. |
|
177 |
comboList useIndex:true. |
|
178 |
top open |
|
179 |
[exEnd] |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
180 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
181 |
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
|
182 |
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
|
183 |
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
|
184 |
(see ListEntry, LabelAndIcon and Text classes) |
682 | 185 |
[exBegin] |
186 |
|top comboList l| |
|
187 |
||
188 |
top := StandardSystemView label:'fruit chooser'. |
|
189 |
top extent:(300 @ 200). |
|
190 |
||
191 |
comboList := ComboListView in:top. |
|
192 |
comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
193 |
comboList bottomInset:(comboList preferredExtent y negated). |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
194 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
195 |
l := OrderedCollection new. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
196 |
l add:(Text string:'apples' color:Color red). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
197 |
l add:(Text string:'bananas' color:Color red). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
198 |
l add:(Text string:'grape' color:Color red). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
199 |
l add:(Text string:'lemon' color:Color red). |
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:'margaritas' color:Color green darkened darkened). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
202 |
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
|
203 |
l add:'='. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
204 |
l add:(Text string:'smalltalk' color:Color blue). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
205 |
l add:(Text string:'c++' color:Color blue). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
206 |
l add:(Text string:'eiffel' color:Color blue). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
207 |
l add:(Text string:'java' color:Color blue). |
682 | 208 |
comboList list:l. |
209 |
comboList values:#(apples bananas grape lemon |
|
210 |
nil |
|
211 |
'mhmh - so good' 'makes headache' |
|
212 |
nil |
|
213 |
'great' 'another headache' 'not bad' 'neat'). |
|
214 |
comboList selection:'apples'. |
|
215 |
comboList action:[:what | Transcript show:'you selected: '; showCR:what]. |
|
216 |
top open |
|
217 |
[exEnd] |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
218 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
219 |
with values different from the label strings: |
682 | 220 |
[exBegin] |
221 |
|top comboList| |
|
222 |
||
223 |
top := StandardSystemView label:'language chooser'. |
|
224 |
top extent:(300 @ 200). |
|
225 |
||
226 |
comboList := ComboListView in:top. |
|
227 |
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
|
228 |
|
682 | 229 |
comboList list:( #( |
230 |
'usa' |
|
231 |
'uk' |
|
232 |
'france' |
|
233 |
'germany' |
|
234 |
'italy' |
|
235 |
) collect:[:country | |
|
236 |
LabelAndIcon |
|
237 |
icon:(Image fromFile:'bitmaps/xpmBitmaps/countries/' , country , '.xpm') |
|
238 |
string:country |
|
239 |
] |
|
240 |
). |
|
241 |
comboList values:#(us england france germany italy). |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
242 |
|
682 | 243 |
comboList action:[:what | Transcript show:'you selected: '; showCR:what]. |
244 |
comboList bottomInset:(comboList preferredExtent y negated). |
|
245 |
top open |
|
246 |
[exEnd] |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
247 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
248 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
249 |
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
|
250 |
the defaults are setup to allow a SelectionInList directly as model: |
682 | 251 |
[exBegin] |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
252 |
|p model| |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
253 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
254 |
model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
255 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
256 |
p := ComboListView label:'healthy fruit'. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
257 |
p model:model. |
682 | 258 |
p openAt:(Screen current center). |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
259 |
model inspect |
682 | 260 |
[exEnd] |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
261 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
262 |
model provides selection; list is explicit: |
682 | 263 |
[exBegin] |
131 | 264 |
|model top b| |
265 |
||
266 |
model := 'foo' asValue. |
|
267 |
||
268 |
top := StandardSystemView new. |
|
269 |
top extent:(300 @ 200). |
|
270 |
||
271 |
b := ComboListView in:top. |
|
272 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
273 |
b bottomInset:(b preferredExtent y negated). |
|
274 |
||
275 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
310 | 276 |
b model:model. |
131 | 277 |
|
278 |
top openModal. |
|
184 | 279 |
Transcript showCR:('comboBox''s value: ' , model value). |
682 | 280 |
[exEnd] |
131 | 281 |
|
282 |
||
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
283 |
a comboListView and a SelectionInListView on the same model: |
682 | 284 |
[exBegin] |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
285 |
|p slv model| |
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 |
model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
288 |
model selection:'apples'. |
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 |
p := ComboListView on:model. |
682 | 291 |
p openAt:(Screen current center). |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
292 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
293 |
slv := SelectionInListView on:model. |
682 | 294 |
slv openAt:(Screen current center + (100@100)). |
295 |
[exEnd] |
|
296 |
||
297 |
||
298 |
like above, using index: |
|
299 |
[exBegin] |
|
300 |
|p slv model| |
|
301 |
||
302 |
model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
303 |
model selection:'apples'. |
|
304 |
||
305 |
p := ComboListView on:model. |
|
306 |
p openAt:(Screen current center). |
|
307 |
||
308 |
slv := SelectionInListView on:model. |
|
309 |
slv openAt:(Screen current center + (100@100)). |
|
310 |
[exEnd] |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
311 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
312 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
313 |
two comboListViews on the same model, different aspects: |
682 | 314 |
[exBegin] |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
315 |
|top panel p model| |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
316 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
317 |
model := Plug new. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
318 |
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
|
319 |
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
|
320 |
model respondTo:#meals with:[#(taco burrito enchilada)]. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
321 |
model respondTo:#drinks with:[#(margarita water corona)]. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
322 |
|
682 | 323 |
top := StandardSystemView label:'meal chooser'. |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
324 |
top extent:(150@150). |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
325 |
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
|
326 |
panel horizontalLayout:#fitSpace. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
327 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
328 |
p := ComboListView label:'meals'. |
682 | 329 |
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
|
330 |
panel add:p. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
331 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
332 |
p := ComboListView label:'drinks'. |
682 | 333 |
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
|
334 |
panel add:p. |
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 |
top open |
682 | 337 |
[exEnd] |
307
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 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
340 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
341 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
342 |
with separate list- and indexHolders: |
682 | 343 |
[exBegin] |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
344 |
|p selectionHolder listHolder| |
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 |
listHolder := #('apples' 'bananas' 'grape' 'lemon' 'margaritas') asValue. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
347 |
selectionHolder := 'apples' asValue. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
348 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
349 |
p := ComboListView label:'healthy fruit'. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
350 |
p listHolder:listHolder. |
310 | 351 |
p model:selectionHolder. |
682 | 352 |
p openAt:(Screen current center). |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
353 |
selectionHolder inspect |
682 | 354 |
[exEnd] |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
355 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
356 |
using different values: |
682 | 357 |
[exBegin] |
358 |
|p priceHolder listHolder prices priceField| |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
359 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
360 |
listHolder := #('apples' 'bananas' 'grape' 'lemon' 'margaritas') asValue. |
682 | 361 |
prices := #(10 10 5 15 50). |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
362 |
|
682 | 363 |
priceHolder := nil asValue. |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
364 |
|
682 | 365 |
p := ComboListView new. |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
366 |
p listHolder:listHolder. |
682 | 367 |
p model:priceHolder. |
368 |
p values:prices. |
|
369 |
p openAt:(Screen current center). |
|
370 |
||
371 |
priceField := EditField new. |
|
372 |
priceField readOnly:true. |
|
373 |
priceField model:(TypeConverter onNumberValue:priceHolder). |
|
374 |
priceField openAt:(Screen current center + (10@10)). |
|
375 |
[exEnd] |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
376 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
377 |
|
131 | 378 |
in a dialog: |
682 | 379 |
[exBegin] |
131 | 380 |
|model1 model2 dialog b| |
381 |
||
382 |
model1 := 'foo' asValue. |
|
383 |
model2 := 'bar' asValue. |
|
384 |
||
385 |
dialog := Dialog new. |
|
386 |
(dialog addTextLabel:'ComboList example:') adjust:#left. |
|
387 |
dialog addVerticalSpace. |
|
388 |
||
389 |
(b := dialog addComboListOn:model1 tabable:true). |
|
390 |
b list:#('fee' 'foe' 'foo'). |
|
391 |
dialog addVerticalSpace. |
|
392 |
||
393 |
(b := dialog addComboListOn:model2 tabable:true). |
|
394 |
b list:#('bar' 'baz' 'baloo'). |
|
395 |
dialog addVerticalSpace. |
|
396 |
||
397 |
dialog addOkButton. |
|
398 |
||
399 |
dialog open. |
|
400 |
||
184 | 401 |
Transcript showCR:('1st comboBox''s value: ' , model1 value). |
402 |
Transcript showCR:('2nd comboBox''s value: ' , model2 value). |
|
682 | 403 |
[exEnd] |
131 | 404 |
" |
405 |
! ! |
|
406 |
||
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
407 |
!ComboListView class methodsFor:'defaults'! |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
408 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
409 |
defaultAspectMessage |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
410 |
^ #selection |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
411 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
412 |
"Created: 27.2.1997 / 15:23:13 / cg" |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
413 |
! |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
414 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
415 |
defaultChangeMessage |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
416 |
^ #selection: |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
417 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
418 |
"Created: 27.2.1997 / 15:23:18 / cg" |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
419 |
! ! |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
420 |
|
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
421 |
!ComboListView methodsFor:'accessing-behavior'! |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
422 |
|
501 | 423 |
useIndex |
424 |
"specify, if the selected components value or its index in the |
|
425 |
list should be sent to the model. The default is its value." |
|
426 |
||
427 |
^ useIndex |
|
428 |
! |
|
429 |
||
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
430 |
useIndex:aBoolean |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
431 |
"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
|
432 |
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
|
433 |
|
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
434 |
useIndex := aBoolean. |
682 | 435 |
|
684 | 436 |
"/ "/ change the aspectMessage - but only if it has not yet been |
437 |
"/ "/ changed explicitly |
|
438 |
"/ useIndex ifTrue:[ |
|
439 |
"/ changeMsg == #selection: ifTrue:[ |
|
440 |
"/ changeMsg := #selectionIndex:. |
|
441 |
"/ aspectMsg := #selectionIndex. |
|
442 |
"/ ] |
|
443 |
"/ ] ifFalse:[ |
|
444 |
"/ changeMsg == #selectionIndex: ifTrue:[ |
|
445 |
"/ changeMsg := #selection:. |
|
446 |
"/ aspectMsg := #selection. |
|
447 |
"/ ] |
|
448 |
"/ ]. |
|
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
449 |
|
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
450 |
"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
|
451 |
"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
|
452 |
! |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
453 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
454 |
values:aCollection |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
455 |
"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
|
456 |
passed via the actionBlock." |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
457 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
458 |
values := aCollection. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
459 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
460 |
"Created: 27.2.1997 / 15:10:12 / cg" |
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
461 |
! ! |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
462 |
|
131 | 463 |
!ComboListView methodsFor:'accessing-components'! |
464 |
||
465 |
label |
|
181 | 466 |
"return the label component" |
131 | 467 |
|
468 |
^ field |
|
469 |
||
470 |
"Modified: 28.2.1996 / 15:10:50 / cg" |
|
471 |
"Created: 28.2.1996 / 15:13:51 / cg" |
|
472 |
! ! |
|
473 |
||
215 | 474 |
!ComboListView methodsFor:'accessing-contents'! |
475 |
||
536 | 476 |
contents |
477 |
"get the current value - either in the fields model |
|
478 |
or directly" |
|
479 |
||
480 |
|m| |
|
481 |
||
482 |
(m := field model) notNil ifTrue:[ |
|
1295 | 483 |
^ m value |
536 | 484 |
] ifFalse:[ |
1295 | 485 |
^ field label |
536 | 486 |
] |
487 |
! |
|
488 |
||
215 | 489 |
contents:something |
272 | 490 |
"set the current value - either in the fields model |
491 |
or directly" |
|
492 |
||
215 | 493 |
|m| |
494 |
||
495 |
(m := field model) notNil ifTrue:[ |
|
1295 | 496 |
m value:something |
215 | 497 |
] ifFalse:[ |
1295 | 498 |
field label:something |
215 | 499 |
] |
500 |
||
501 |
"Created: 15.7.1996 / 13:16:49 / cg" |
|
272 | 502 |
"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
|
503 |
! |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
504 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
505 |
selection:something |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
506 |
"set the contents of my field; questionable" |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
507 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
508 |
self contents:something |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
509 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
510 |
"Created: 27.2.1997 / 15:07:37 / cg" |
215 | 511 |
! ! |
512 |
||
131 | 513 |
!ComboListView methodsFor:'initialization'! |
514 |
||
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
515 |
initialize |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
516 |
useIndex isNil ifTrue:[useIndex := false]. |
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
517 |
|
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
518 |
super initialize. |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
519 |
|
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
520 |
"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
|
521 |
"Modified: 27.2.1997 / 15:23:24 / cg" |
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
522 |
! |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
523 |
|
131 | 524 |
initializeField |
525 |
field := Label in:self. |
|
519 | 526 |
field level:-1; borderWidth:0. |
131 | 527 |
field adjust:#left. |
528 |
||
529 |
" |
|
530 |
|b| |
|
531 |
||
532 |
b := ComboListView new. |
|
533 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
534 |
b open |
|
535 |
" |
|
536 |
||
537 |
"Created: 28.2.1996 / 15:13:46 / cg" |
|
538 |
"Modified: 28.2.1996 / 15:18:40 / cg" |
|
539 |
! ! |
|
540 |
||
215 | 541 |
!ComboListView methodsFor:'private'! |
542 |
||
543 |
getValueFromModel |
|
1206 | 544 |
|selection idx aspect newContents| |
278 | 545 |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
546 |
(model notNil and:[aspectMsg notNil]) ifTrue:[ |
682 | 547 |
"/ kludge - try #value if aspect is the default and |
548 |
"/ not understood by the model |
|
549 |
"/ this allows a valueHolder to be used, even |
|
550 |
"/ 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
|
551 |
|
682 | 552 |
aspect := aspectMsg. |
553 |
aspect == self class defaultAspectMessage ifTrue:[ |
|
554 |
(model respondsTo:aspect) ifFalse:[ |
|
555 |
aspect := #value |
|
556 |
] |
|
557 |
]. |
|
558 |
||
1729 | 559 |
aspect == #value ifTrue:[ |
560 |
selection := model value |
|
561 |
] ifFalse:[ |
|
562 |
selection := model perform:aspect. |
|
563 |
]. |
|
309
f2ae122f6dad
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
307
diff
changeset
|
564 |
|
682 | 565 |
selection notNil ifTrue:[ |
566 |
values notNil ifTrue:[ |
|
567 |
idx := values indexOf:selection |
|
568 |
] ifFalse:[ |
|
569 |
useIndex ifTrue:[ |
|
570 |
idx := selection |
|
571 |
] ifFalse:[ |
|
572 |
self contents:selection. |
|
573 |
^ self. |
|
574 |
] |
|
575 |
]. |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
576 |
|
1206 | 577 |
newContents := list at:idx ifAbsent:nil. |
578 |
]. |
|
579 |
self contents:newContents |
|
215 | 580 |
]. |
581 |
||
1729 | 582 |
"Created: / 15.7.1996 / 12:28:53 / cg" |
583 |
"Modified: / 1.3.2000 / 15:20:24 / cg" |
|
215 | 584 |
! ! |
585 |
||
291 | 586 |
!ComboListView methodsFor:'queries'! |
587 |
||
588 |
specClass |
|
598 | 589 |
"XXX no longer needed (inherited default works here)" |
590 |
||
291 | 591 |
self class == ComboListView ifTrue:[ |
1295 | 592 |
^ ComboListSpec |
291 | 593 |
]. |
301 | 594 |
^ super specClass |
291 | 595 |
|
598 | 596 |
"Modified: / 31.10.1997 / 19:49:34 / cg" |
291 | 597 |
! ! |
598 |
||
131 | 599 |
!ComboListView methodsFor:'user interaction'! |
600 |
||
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
601 |
select:anIndex |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
602 |
"sent from the popped menu, when an item was selected" |
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
603 |
|
368 | 604 |
|label value chg| |
238 | 605 |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
606 |
values isNil ifTrue:[ |
682 | 607 |
value := anIndex. |
608 |
useIndex ifFalse:[ |
|
609 |
value := list at:anIndex. |
|
610 |
] |
|
283
7441b4d65776
additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
611 |
] ifFalse:[ |
682 | 612 |
value := values at:anIndex |
283
7441b4d65776
additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
613 |
]. |
7441b4d65776
additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
614 |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
615 |
label := list at:anIndex. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
616 |
|
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
617 |
field label:label. |
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
618 |
|
293
e707cc62ee30
first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
619 |
" |
e707cc62ee30
first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
620 |
ST-80 style model notification ... |
e707cc62ee30
first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
621 |
this updates the model (typically, a ValueHolder) |
e707cc62ee30
first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
622 |
" |
309
f2ae122f6dad
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
307
diff
changeset
|
623 |
(model notNil and:[changeMsg notNil]) ifTrue:[ |
682 | 624 |
"/ kludge - try #value: if changeMsg is the default and |
625 |
"/ not understood by the model |
|
626 |
"/ this allows a valueHolder to be used, even |
|
627 |
"/ 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
|
628 |
|
682 | 629 |
chg := changeMsg. |
630 |
chg == self class defaultChangeMessage ifTrue:[ |
|
631 |
(model respondsTo:chg) ifFalse:[ |
|
632 |
chg := #value: |
|
633 |
] |
|
634 |
]. |
|
309
f2ae122f6dad
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
307
diff
changeset
|
635 |
|
682 | 636 |
self sendChangeMessage:chg with:value |
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
637 |
]. |
131 | 638 |
pullDownButton turnOff. |
639 |
||
293
e707cc62ee30
first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
640 |
" |
e707cc62ee30
first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
641 |
ST/X style actionBlock evaluation ... |
e707cc62ee30
first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
642 |
" |
283
7441b4d65776
additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
643 |
action notNil ifTrue:[ |
682 | 644 |
action value:value |
283
7441b4d65776
additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
645 |
]. |
7441b4d65776
additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
646 |
|
307
b33b48f2a1a3
examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
647 |
"Created: 27.2.1997 / 15:18:44 / cg" |
310 | 648 |
"Modified: 28.2.1997 / 13:50:17 / cg" |
131 | 649 |
! ! |
650 |
||
270 | 651 |
!ComboListView class methodsFor:'documentation'! |
131 | 652 |
|
653 |
version |
|
2825 | 654 |
^ '$Header: /cvs/stx/stx/libwidg2/ComboListView.st,v 1.38 2005-06-07 15:01:59 cg Exp $' |
131 | 655 |
! ! |