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