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