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