author | Claus Gittinger <cg@exept.de> |
Thu, 27 Feb 1997 10:05:15 +0100 | |
changeset 1064 | dba203683e94 |
parent 1063 | b315e2580bc7 |
child 1065 | 01c863929ddc |
permissions | -rw-r--r-- |
20 | 1 |
" |
2 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
59 | 3 |
All Rights Reserved |
20 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
Button subclass:#PopUpList |
|
1063 | 14 |
instanceVariableNames:'menu menuAction values useIndex listMsg defaultLabel listHolder' |
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
15 |
classVariableNames:'' |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
16 |
poolDictionaries:'' |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
17 |
category:'Views-Interactors' |
20 | 18 |
! |
19 |
||
998 | 20 |
!PopUpList class methodsFor:'documentation'! |
38 | 21 |
|
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
59 | 25 |
All Rights Reserved |
38 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
38 |
a PopUpList is basically a button with a popup menu. |
|
39 |
The PopUpLists label is showing the current selection from the |
|
40 |
list. |
|
121 | 41 |
When an entry is selected, an actionBlock (if nonNil) is evaluated |
42 |
and (if nonNil), the model is notified via the changeMessage. |
|
125 | 43 |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
44 |
If no model is set, the list is assumed to be a static list, which |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
45 |
is defined via #list:, and the popUpList evaluates the action block, |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
46 |
as defined via #action:. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
47 |
|
1063 | 48 |
If a model is provided, it should return the list from the listMessage |
49 |
(default is #list) and the current selected items index via the aspectMessage |
|
50 |
(default is #selection or: #selectionIndex, depending on the setting of useIndex). |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
51 |
|
1063 | 52 |
The defaults are set to allows a PopUpList to be used with a SelectionInList |
53 |
as model without further setup. |
|
121 | 54 |
(if used with some other model, either use an adaptor, or set the |
1063 | 55 |
change/aspect and/or listMessage to something else ..) |
125 | 56 |
|
585 | 57 |
[Instance variables:] |
125 | 58 |
|
1063 | 59 |
menu helpers for the popup menu |
60 |
menuAction |
|
61 |
values |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
62 |
|
1063 | 63 |
useIndex <Boolean> if true, the index of the selected entry |
64 |
is passed to the action block and the |
|
65 |
model in a change-message. |
|
66 |
If false (the default), the value is passed. |
|
67 |
Notice that the default changeMessage is |
|
68 |
#selection:, which is not ok to be used |
|
69 |
with useIndex:true and a selectionInList model. |
|
70 |
(set the changeMessage to #selectionIndex: then) |
|
125 | 71 |
|
1063 | 72 |
listMsg <Symbol> message to aquire a new list from the |
73 |
model. Default is #list. |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
74 |
|
125 | 75 |
|
1063 | 76 |
listHolder <Object> if non-nil, this object is assumed to return the |
77 |
list via the listMsg (instead of the model). |
|
78 |
Default is nil. |
|
585 | 79 |
|
80 |
[see also:] |
|
1063 | 81 |
SelectionInListView |
82 |
SelectionInList |
|
585 | 83 |
|
84 |
[author:] |
|
1063 | 85 |
Claus Gittinger |
63 | 86 |
" |
87 |
! |
|
38 | 88 |
|
63 | 89 |
examples |
90 |
" |
|
1063 | 91 |
non-MVC use: |
92 |
[exBegin] |
|
38 | 93 |
|p| |
94 |
p := PopUpList label:'healthy fruit'. |
|
119 | 95 |
p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
38 | 96 |
p open |
1063 | 97 |
[exEnd] |
38 | 98 |
|
99 |
||
100 |
with an initial selection: |
|
1063 | 101 |
[exBegin] |
38 | 102 |
|p| |
103 |
p := PopUpList label:'dummy'. |
|
119 | 104 |
p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
38 | 105 |
p selection:'apples'. |
106 |
p open |
|
1063 | 107 |
[exEnd] |
38 | 108 |
|
109 |
||
110 |
with separating lines: |
|
1063 | 111 |
[exBegin] |
38 | 112 |
|p| |
119 | 113 |
p := PopUpList label:'fruit'. |
114 |
p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas'). |
|
38 | 115 |
p selection:'apples'. |
116 |
p open |
|
1063 | 117 |
[exEnd] |
77 | 118 |
|
119 |
||
120 |
with an action: |
|
1063 | 121 |
[exBegin] |
77 | 122 |
|p| |
123 |
p := PopUpList label:'dummy'. |
|
119 | 124 |
p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas'). |
77 | 125 |
p selection:'apples'. |
655 | 126 |
p action:[:what | Transcript showCR:'you selected: ' , what]. |
77 | 127 |
p open |
1063 | 128 |
[exEnd] |
77 | 129 |
|
130 |
||
119 | 131 |
sometimes, you may like the index instead of the value: |
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
132 |
(notice, that the separating line counts, so you have to take care ...) |
1063 | 133 |
[exBegin] |
119 | 134 |
|p| |
135 |
p := PopUpList label:'dummy'. |
|
136 |
p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas'). |
|
137 |
p selection:'apples'. |
|
655 | 138 |
p action:[:what | Transcript show:'you selected: '; showCR:what]. |
119 | 139 |
p useIndex:true. |
140 |
p open |
|
1063 | 141 |
[exEnd] |
119 | 142 |
|
143 |
||
144 |
since the list is actually a popupMenu, you can add double-separators: |
|
1063 | 145 |
[exBegin] |
119 | 146 |
|p| |
147 |
p := PopUpList label:'dummy'. |
|
148 |
p list:#('apples' 'bananas' 'grape' 'lemon' |
|
1063 | 149 |
'=' |
150 |
'margaritas' 'pina colada' |
|
151 |
'=' |
|
152 |
'smalltalk' 'c++' 'eiffel' 'java'). |
|
119 | 153 |
p values:#(apples bananas grape lemon |
1063 | 154 |
nil |
155 |
'mhmh - so good' 'makes headache' |
|
156 |
nil |
|
157 |
'great' 'another headache' 'not bad' 'neat'). |
|
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
158 |
p selection:'apples'. |
655 | 159 |
p action:[:what | Transcript show:'you selected: '; showCR:what]. |
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
160 |
p open |
1063 | 161 |
[exEnd] |
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
162 |
|
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
163 |
|
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
164 |
since the list is actually represented by a menuView, |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
165 |
which itself is inheriting from listView, which itself can display |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
166 |
things different from strings, arbitrary lists can be constructed: |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
167 |
(see ListEntry classes) |
1063 | 168 |
[exBegin] |
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
169 |
|p l| |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
170 |
p := PopUpList label:'dummy'. |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
171 |
l := OrderedCollection new. |
1064 | 172 |
l add:(ColoredListEntry string:'apples' color:Color red). |
173 |
l add:(ColoredListEntry string:'bananas' color:Color red). |
|
174 |
l add:(ColoredListEntry string:'grape' color:Color red). |
|
175 |
l add:(ColoredListEntry string:'lemon' color:Color red). |
|
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
176 |
l add:'='. |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
177 |
l add:(ColoredListEntry string:'margaritas' color:Color green darkened darkened). |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
178 |
l add:(ColoredListEntry string:'pina colada' color:Color green darkened darkened). |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
179 |
l add:'='. |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
180 |
l add:(ColoredListEntry string:'smalltalk' color:Color blue). |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
181 |
l add:(ColoredListEntry string:'c++' color:Color blue). |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
182 |
l add:(ColoredListEntry string:'eiffel' color:Color blue). |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
183 |
l add:(ColoredListEntry string:'java' color:Color blue). |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
184 |
p list:l. |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
185 |
p values:#(apples bananas grape lemon |
1063 | 186 |
nil |
187 |
'mhmh - so good' 'makes headache' |
|
188 |
nil |
|
189 |
'great' 'another headache' 'not bad' 'neat'). |
|
119 | 190 |
p selection:'apples'. |
655 | 191 |
p action:[:what | Transcript show:'you selected: '; showCR:what]. |
119 | 192 |
p open |
1063 | 193 |
[exEnd] |
119 | 194 |
|
195 |
||
77 | 196 |
with values different from the label strings: |
1063 | 197 |
[exBegin] |
77 | 198 |
|p| |
199 |
p := PopUpList label:'dummy'. |
|
119 | 200 |
p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas'). |
77 | 201 |
p selection:'apples'. |
202 |
p values:#(10 20 30 40 nil 50). |
|
655 | 203 |
p action:[:what | Transcript show:'you selected: '; showCR:what]. |
77 | 204 |
p open |
1063 | 205 |
[exEnd] |
119 | 206 |
|
121 | 207 |
|
1064 | 208 |
with a model (see in the inspector, how the index-holders value changes) |
1063 | 209 |
the defaults are setup to allow a SelectionInList directly as model: |
210 |
[exBegin] |
|
119 | 211 |
|p model| |
212 |
||
213 |
model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
214 |
||
215 |
p := PopUpList label:'healthy fruit'. |
|
216 |
p model:model. |
|
217 |
p open. |
|
1063 | 218 |
model inspect |
219 |
[exEnd] |
|
121 | 220 |
|
20 | 221 |
|
125 | 222 |
a popupList and a SelectionInListView on the same model: |
1063 | 223 |
[exBegin] |
125 | 224 |
|p slv model| |
225 |
||
226 |
model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
227 |
model selection:'apples'. |
|
228 |
||
229 |
p := PopUpList on:model. |
|
1064 | 230 |
p open. |
231 |
||
232 |
slv := SelectionInListView on:model. |
|
233 |
slv open. |
|
234 |
[exEnd] |
|
235 |
||
236 |
||
237 |
dynamically changing the list (click button(s) to change): |
|
238 |
[exBegin] |
|
239 |
|p slv model b| |
|
240 |
||
241 |
model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
242 |
model selection:'apples'. |
|
243 |
||
244 |
p := PopUpList on:model. |
|
125 | 245 |
p open. |
246 |
||
247 |
slv := SelectionInListView on:model. |
|
248 |
slv open. |
|
249 |
||
1064 | 250 |
b := Button label:'long list' action:[model list:#('1' '2' '3' '4' '5' '6')]. |
251 |
b open. |
|
252 |
b := Button label:'short list' action:[model list:#('1' '2' '3')]. |
|
253 |
b open. |
|
254 |
||
1063 | 255 |
[exEnd] |
256 |
||
257 |
||
125 | 258 |
|
127 | 259 |
two PopUpLists on the same model, different aspects: |
1063 | 260 |
[exBegin] |
121 | 261 |
|top panel p model| |
20 | 262 |
|
121 | 263 |
model := Plug new. |
655 | 264 |
model respondTo:#eat: with:[:val | Transcript showCR:'eat: ' , val]. |
265 |
model respondTo:#drink: with:[:val | Transcript showCR:'drink: ' , val]. |
|
121 | 266 |
model respondTo:#meals with:[#(taco burrito enchilada)]. |
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
267 |
model respondTo:#drinks with:[#(margarita water corona)]. |
20 | 268 |
|
121 | 269 |
top := StandardSystemView new. |
270 |
top extent:(100@100). |
|
271 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
272 |
panel horizontalLayout:#fitSpace. |
|
77 | 273 |
|
121 | 274 |
p := PopUpList label:'meals'. |
126 | 275 |
p model:model; listMessage:#meals; aspect:nil; change:#eat:. |
121 | 276 |
panel add:p. |
119 | 277 |
|
121 | 278 |
p := PopUpList label:'drinks'. |
126 | 279 |
p model:model; listMessage:#drinks; aspect:nil; change:#drink:. |
121 | 280 |
panel add:p. |
77 | 281 |
|
121 | 282 |
top open |
1063 | 283 |
[exEnd] |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
284 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
285 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
286 |
with separate list- and indexHolders: |
1063 | 287 |
[exBegin] |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
288 |
|p selectionHolder listHolder| |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
289 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
290 |
listHolder := #('apples' 'bananas' 'grape' 'lemon' 'margaritas') asValue. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
291 |
selectionHolder := 'apples' asValue. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
292 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
293 |
p := PopUpList label:'healthy fruit'. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
294 |
p listHolder:listHolder. |
1064 | 295 |
p selectionHolder:selectionHolder. |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
296 |
p open. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
297 |
selectionHolder inspect |
1063 | 298 |
[exEnd] |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
299 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
300 |
same, using index: |
1063 | 301 |
[exBegin] |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
302 |
|p selectionIndexHolder listHolder| |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
303 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
304 |
listHolder := #('apples' 'bananas' 'grape' 'lemon' 'margaritas') asValue. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
305 |
selectionIndexHolder := 3 asValue. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
306 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
307 |
p := PopUpList new. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
308 |
p listHolder:listHolder. |
1064 | 309 |
p selectionHolder:selectionIndexHolder. |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
310 |
p useIndex:true. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
311 |
p open. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
312 |
selectionIndexHolder inspect |
1063 | 313 |
[exEnd] |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
314 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
315 |
|
121 | 316 |
" |
20 | 317 |
! ! |
318 |
||
998 | 319 |
!PopUpList class methodsFor:'defaults'! |
125 | 320 |
|
321 |
defaultAspectMessage |
|
322 |
^ #selection |
|
323 |
! |
|
324 |
||
325 |
defaultChangeMessage |
|
326 |
^ #selection: |
|
205 | 327 |
! |
328 |
||
329 |
defaultListMessage |
|
330 |
^ #list |
|
331 |
! ! |
|
332 |
||
333 |
!PopUpList methodsFor:'accessing'! |
|
334 |
||
335 |
contents |
|
336 |
^ self label |
|
337 |
! |
|
338 |
||
339 |
contents:con |
|
340 |
^ self selection:con |
|
341 |
||
684 | 342 |
"Modified: 25.5.1996 / 14:20:57 / cg" |
205 | 343 |
! |
344 |
||
1035 | 345 |
defaultLabel:aString |
346 |
"set the defaultLabel, to be shown if nothing is selected" |
|
347 |
||
348 |
defaultLabel := aString |
|
349 |
! |
|
350 |
||
205 | 351 |
list |
352 |
"return the list - i.e. the values shown in the pop-up list" |
|
353 |
||
354 |
^ menu labels |
|
355 |
! |
|
356 |
||
357 |
list:aList |
|
358 |
"set the list - i.e. the values shown in the pop-up list" |
|
359 |
||
360 |
self createMenuFor:aList. |
|
361 |
realized ifTrue:[ |
|
362 |
self computeLabelSize |
|
363 |
] |
|
364 |
||
365 |
" |
|
366 |
|p| |
|
367 |
p := PopUpList label:'fruit ?'. |
|
368 |
p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
655 | 369 |
p action:[:val | Transcript showCR:'selected: ' , val printString]. |
205 | 370 |
p open |
371 |
" |
|
372 |
! |
|
373 |
||
374 |
selection:indexOrString |
|
375 |
"set (force) a selection - usually done to set |
|
376 |
an initial selection without updating others" |
|
377 |
||
378 |
|index wasFix| |
|
379 |
||
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
380 |
menu isNil ifTrue:[ |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
381 |
self getListFromModel. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
382 |
]. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
383 |
menu isNil ifTrue:[^ self]. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
384 |
|
205 | 385 |
index := menu indexOf:indexOrString. |
1035 | 386 |
index == 0 ifTrue:[ |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
387 |
self label:defaultLabel. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
388 |
^ self |
1035 | 389 |
]. |
205 | 390 |
|
391 |
"kludge: dont want label to resize ..." |
|
392 |
wasFix := fixSize. fixSize := true. |
|
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
393 |
self label:(menu labels at:index) printString. |
205 | 394 |
fixSize := wasFix |
395 |
||
396 |
" |
|
397 |
|p| |
|
398 |
p := PopUpList label:'what fruit ?'. |
|
399 |
p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
400 |
p selection:'grape'. |
|
401 |
p open |
|
402 |
||
403 |
|p| |
|
404 |
p := PopUpList label:'what fruit ?'. |
|
405 |
p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
406 |
p selection:'blabla'. |
|
407 |
p open |
|
408 |
" |
|
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
409 |
|
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
410 |
"Modified: 8.2.1996 / 12:55:01 / cg" |
205 | 411 |
! |
412 |
||
593 | 413 |
values:aList |
414 |
"set a value list - these are reported via the action or changeSymbol instead of |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
415 |
the label strings." |
593 | 416 |
|
417 |
values := aList. |
|
418 |
menu args:(1 to:aList size). |
|
419 |
||
420 |
" |
|
421 |
|p| |
|
422 |
p := PopUpList label:'fruit ?'. |
|
423 |
p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
424 |
p values:#(1 2 3 4 'mhmh - good'). |
|
655 | 425 |
p action:[:val | Transcript showCR:'selected: ' , val printString]. |
593 | 426 |
p open. |
427 |
" |
|
428 |
! ! |
|
429 |
||
430 |
!PopUpList methodsFor:'accessing-behavior'! |
|
431 |
||
432 |
action:aOneArgBlock |
|
433 |
"set the action to be performed on selection changes; |
|
434 |
the argument, aOneArgBlock will be evaluated with the |
|
435 |
selection-value as argument" |
|
436 |
||
437 |
menuAction := aOneArgBlock |
|
438 |
! |
|
439 |
||
205 | 440 |
useIndex:aBoolean |
441 |
"tell the popuplist to pass the index (instead of the value) |
|
442 |
to both the actionBlock and model. Notice, that if you use a model, |
|
443 |
the default changeSelector is not ok for using index and a SelectionInList" |
|
444 |
||
445 |
useIndex := aBoolean |
|
446 |
||
447 |
" |
|
448 |
|p| |
|
449 |
p := PopUpList label:'fruit ?'. |
|
450 |
p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
655 | 451 |
p action:[:val | Transcript showCR:'selected: ' , val printString]. |
205 | 452 |
p open. |
453 |
" |
|
454 |
" |
|
455 |
|p| |
|
456 |
p := PopUpList label:'fruit ?'. |
|
457 |
p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
655 | 458 |
p action:[:val | Transcript showCR:'selected: ' , val printString]. |
205 | 459 |
p useIndex:true. |
460 |
p open. |
|
461 |
" |
|
125 | 462 |
! ! |
463 |
||
205 | 464 |
!PopUpList methodsFor:'accessing-mvc'! |
465 |
||
466 |
addModelInterfaceTo:aDictionary |
|
467 |
"see comment in View>>modelInterface" |
|
468 |
||
469 |
super addModelInterfaceTo:aDictionary. |
|
470 |
aDictionary at:#listMessage put:listMsg |
|
1063 | 471 |
|
472 |
"Modified: 26.2.1997 / 19:08:04 / cg" |
|
205 | 473 |
! |
474 |
||
475 |
getListFromModel |
|
1063 | 476 |
"if I have a listHolder, ask it for the list; |
477 |
otherwise, if I have a model and a listMsg, get my list from there" |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
478 |
|
1063 | 479 |
listHolder notNil ifTrue:[ |
480 |
self list:listHolder value |
|
481 |
] ifFalse:[ |
|
482 |
(listMsg notNil and:[model notNil]) ifTrue:[ |
|
483 |
self list:(model perform:listMsg). |
|
484 |
]. |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
485 |
] |
1063 | 486 |
|
487 |
"Modified: 26.2.1997 / 19:07:36 / cg" |
|
205 | 488 |
! |
489 |
||
490 |
getSelectionFromModel |
|
491 |
"if I have a model and an aspectMsg, get my current value from it" |
|
492 |
||
1063 | 493 |
(model notNil and:[aspectMsg notNil]) ifTrue:[ |
494 |
self selection:(model perform:aspectMsg) |
|
205 | 495 |
]. |
684 | 496 |
|
1063 | 497 |
"Modified: 26.2.1997 / 18:21:59 / cg" |
498 |
! |
|
499 |
||
500 |
listHolder |
|
501 |
"return the listHolder if any" |
|
502 |
||
503 |
^ listHolder |
|
504 |
! |
|
505 |
||
506 |
listHolder:aValueHolder |
|
507 |
"set the listHolder - if non nil, that one is assumed to provide the |
|
508 |
list via #value. |
|
509 |
If a listHolder was defined, the model is never asked for the list." |
|
510 |
||
511 |
listHolder notNil ifTrue:[ |
|
512 |
listHolder removeDependent:self. |
|
513 |
]. |
|
514 |
listHolder := aValueHolder. |
|
515 |
listHolder notNil ifTrue:[ |
|
516 |
listHolder addDependent:self. |
|
517 |
]. |
|
518 |
shown ifTrue:[ |
|
519 |
self getListFromModel |
|
520 |
] |
|
521 |
||
522 |
"Modified: 26.2.1997 / 19:06:01 / cg" |
|
205 | 523 |
! |
524 |
||
525 |
listMessage |
|
1063 | 526 |
"return the selector by which we ask the model or listHolder for the list. |
527 |
The default is #list. |
|
528 |
If a listHolder was defined, the model is never asked for the list." |
|
205 | 529 |
|
530 |
^ listMsg |
|
1063 | 531 |
|
532 |
"Modified: 26.2.1997 / 19:05:27 / cg" |
|
205 | 533 |
! |
534 |
||
535 |
listMessage:aSelector |
|
536 |
"set the selector by which we ask the model for the list. |
|
1063 | 537 |
The default is #list. |
538 |
If a listHolder was defined, the model is never asked for the list." |
|
205 | 539 |
|
540 |
listMsg := aSelector |
|
1063 | 541 |
|
542 |
"Modified: 26.2.1997 / 19:05:18 / cg" |
|
205 | 543 |
! ! |
544 |
||
545 |
!PopUpList methodsFor:'change & update'! |
|
546 |
||
547 |
update:something with:aParameter from:changedObject |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
548 |
changedObject == listHolder ifTrue:[ |
1063 | 549 |
self getListFromModel. |
550 |
^ self |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
551 |
]. |
205 | 552 |
changedObject == model ifTrue:[ |
1063 | 553 |
(something == aspectMsg |
554 |
or:[something == #selectionIndex]) ifTrue:[ |
|
555 |
self getSelectionFromModel. |
|
556 |
^ self |
|
557 |
]. |
|
558 |
something == listMsg ifTrue:[ |
|
559 |
self getListFromModel. |
|
560 |
]. |
|
561 |
^ self |
|
205 | 562 |
]. |
563 |
super update:something with:aParameter from:changedObject |
|
1063 | 564 |
|
565 |
"Modified: 26.2.1997 / 18:23:27 / cg" |
|
205 | 566 |
! ! |
567 |
||
568 |
!PopUpList methodsFor:'drawing'! |
|
569 |
||
570 |
drawWith:fgColor and:bgColor |
|
571 |
|mmH mmV mW mH| |
|
136 | 572 |
|
205 | 573 |
controller pressed ifTrue:[ |
574 |
super drawWith:enteredFgColor and:enteredBgColor |
|
575 |
] ifFalse:[ |
|
576 |
super drawWith:fgColor and:bgColor. |
|
577 |
]. |
|
578 |
mmH := device horizontalPixelPerMillimeter rounded. |
|
579 |
mmV := device verticalPixelPerMillimeter rounded. |
|
580 |
mW := (device horizontalPixelPerMillimeter * 2.5) rounded. |
|
581 |
mH := (device verticalPixelPerMillimeter * 1.5) rounded. |
|
582 |
||
583 |
self drawEdgesForX:(width - mW - (hSpace*2)) y:(height - mmV // 2) |
|
584 |
width:mW height:mH level:2 |
|
585 |
! |
|
586 |
||
587 |
showActive |
|
588 |
"no need to redraw - will pop menu ontop of me anyway ..." |
|
589 |
||
590 |
^ self |
|
591 |
! |
|
592 |
||
593 |
showPassive |
|
594 |
"no need to redraw - will redraw from unpopped menu anyway ..." |
|
595 |
||
596 |
^ self |
|
597 |
! ! |
|
598 |
||
599 |
!PopUpList methodsFor:'event handling'! |
|
600 |
||
601 |
popMenu |
|
602 |
|org mv w| |
|
603 |
||
604 |
menu notNil ifTrue:[ |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
605 |
self turnOffWithoutRedraw. |
1035 | 606 |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
607 |
menu labels size == 0 ifTrue:[ |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
608 |
^ self |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
609 |
]. |
1035 | 610 |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
611 |
menu font:font. |
136 | 612 |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
613 |
" |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
614 |
adjust the menus width to my current width |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
615 |
" |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
616 |
mv := menu menuView. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
617 |
mv create. "/ stupid: it resizes itself upon first create |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
618 |
w := mv width. "/ to its preferred size. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
619 |
w := w max:(self width - (2 * menu margin) - (menu borderWidth*2)). |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
620 |
mv width:w. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
621 |
mv level:0; borderWidth:0. |
205 | 622 |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
623 |
" |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
624 |
the popupMenu wants Display coordinates in its showAt: method |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
625 |
" |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
626 |
org := device translatePoint:0@0 |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
627 |
from:(self id) |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
628 |
to:(device rootView id). |
205 | 629 |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
630 |
menu showAt:org "resizing:false" |
205 | 631 |
]. |
632 |
! ! |
|
633 |
||
634 |
!PopUpList methodsFor:'initialization'! |
|
635 |
||
636 |
defaultControllerClass |
|
637 |
^ PopUpListController |
|
638 |
! |
|
639 |
||
640 |
initialize |
|
641 |
super initialize. |
|
642 |
||
643 |
controller beTriggerOnDown. |
|
644 |
controller action:[self popMenu]. |
|
645 |
self adjust:#left. |
|
646 |
useIndex := false. |
|
1035 | 647 |
defaultLabel := 'popup'. |
648 |
self label:defaultLabel. |
|
1063 | 649 |
|
205 | 650 |
listMsg := self class defaultListMessage. |
651 |
||
652 |
onLevel := offLevel. |
|
1063 | 653 |
|
654 |
"Modified: 26.2.1997 / 18:23:43 / cg" |
|
136 | 655 |
! ! |
656 |
||
20 | 657 |
!PopUpList methodsFor:'private'! |
658 |
||
659 |
computeLabelSize |
|
660 |
"compute the extent needed to hold the label plus the mark" |
|
661 |
||
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
662 |
|mmH mmV savedLogo longest longestWidth labels| |
20 | 663 |
|
664 |
menu isNil ifTrue:[ |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
665 |
super computeLabelSize |
20 | 666 |
] ifFalse:[ |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
667 |
"hack: simulate logo change to longest menu entry" |
20 | 668 |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
669 |
font := font on:device. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
670 |
longest := logo. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
671 |
logo isNil ifTrue:[ |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
672 |
longestWidth := 0 |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
673 |
] ifFalse:[ |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
674 |
longestWidth := font widthOf:logo. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
675 |
]. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
676 |
labels := menu labels. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
677 |
labels notNil ifTrue:[ |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
678 |
labels do:[:entry | |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
679 |
|this| |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
680 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
681 |
this := font widthOf:entry printString. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
682 |
this > longestWidth ifTrue:[ |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
683 |
longest := entry. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
684 |
longestWidth := this |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
685 |
]. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
686 |
]. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
687 |
]. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
688 |
savedLogo := logo. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
689 |
logo := longest printString. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
690 |
super computeLabelSize. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
691 |
logo := savedLogo. |
20 | 692 |
]. |
693 |
mmH := device horizontalPixelPerMillimeter. |
|
694 |
mmV := device verticalPixelPerMillimeter. |
|
695 |
labelWidth := labelWidth + hSpace + (mmH * 2.5) rounded + hSpace. |
|
696 |
labelHeight := labelHeight max: (mmV * 2) rounded |
|
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
697 |
|
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
698 |
"Modified: 8.2.1996 / 13:00:33 / cg" |
121 | 699 |
! |
700 |
||
701 |
createMenuFor:aList |
|
702 |
menu := PopUpMenu |
|
703 |
labels:aList |
|
704 |
selectors:#select: |
|
705 |
args:(1 to:aList size) |
|
706 |
receiver:self |
|
707 |
for:self. |
|
128 | 708 |
! |
709 |
||
205 | 710 |
realize |
711 |
super realize. |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
712 |
(model notNil or:[listHolder notNil]) ifTrue:[ |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
713 |
self getListFromModel. |
121 | 714 |
]. |
1063 | 715 |
model notNil ifTrue:[ |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
716 |
self getSelectionFromModel. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
717 |
] |
1063 | 718 |
|
719 |
"Modified: 26.2.1997 / 18:23:58 / cg" |
|
121 | 720 |
! ! |
721 |
||
205 | 722 |
!PopUpList methodsFor:'private-controller access'! |
121 | 723 |
|
205 | 724 |
menu |
725 |
"return the menu component" |
|
125 | 726 |
|
205 | 727 |
^ menu |
126 | 728 |
! ! |
729 |
||
136 | 730 |
!PopUpList methodsFor:'queries'! |
731 |
||
732 |
preferredExtent |
|
733 |
"redefined to make certain that the menu is fully defined" |
|
734 |
||
799 | 735 |
"/ If I have an explicit preferredExtent .. |
736 |
||
714
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
737 |
preferredExtent notNil ifTrue:[ |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
738 |
^ preferredExtent |
714
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
739 |
]. |
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
740 |
|
136 | 741 |
menu isNil ifTrue:[ |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
742 |
self getListFromModel |
136 | 743 |
]. |
744 |
self computeLabelSize. |
|
745 |
^ super preferredExtent. |
|
714
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
746 |
|
799 | 747 |
"Modified: 19.7.1996 / 20:45:16 / cg" |
155 | 748 |
! |
749 |
||
750 |
specClass |
|
751 |
self class == PopUpList ifTrue:[^ PopUpListSpec]. |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
752 |
^ super specClass |
136 | 753 |
! ! |
754 |
||
20 | 755 |
!PopUpList methodsFor:'user actions'! |
756 |
||
757 |
select:anEntry |
|
119 | 758 |
"this is sent from the popupmenu when an entry was selected" |
759 |
||
77 | 760 |
|value label| |
761 |
||
119 | 762 |
label := menu labels at:anEntry. |
77 | 763 |
values isNil ifTrue:[ |
1063 | 764 |
value := anEntry. |
765 |
useIndex ifFalse:[ |
|
766 |
value := menu labels at:anEntry. |
|
767 |
] |
|
77 | 768 |
] ifFalse:[ |
1063 | 769 |
value := values at:anEntry |
20 | 770 |
]. |
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
771 |
|
20 | 772 |
self sizeFixed:true. |
77 | 773 |
self label:label printString. |
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
774 |
|
1012 | 775 |
"/ |
776 |
"/ ST-80 way of doing it |
|
777 |
"/ tell my model - if any |
|
778 |
"/ |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
779 |
self sendChangeMessageWith:value. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
780 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
781 |
"/ |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
782 |
"/ ST/X action blocks |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
783 |
"/ |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
784 |
menuAction notNil ifTrue:[ |
1063 | 785 |
menuAction value:value. |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
786 |
]. |
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
787 |
|
1063 | 788 |
"Modified: 26.2.1997 / 18:24:16 / cg" |
20 | 789 |
! ! |
121 | 790 |
|
998 | 791 |
!PopUpList class methodsFor:'documentation'! |
121 | 792 |
|
205 | 793 |
version |
1064 | 794 |
^ '$Header: /cvs/stx/stx/libwidg/PopUpList.st,v 1.34 1997-02-27 09:05:15 cg Exp $' |
121 | 795 |
! ! |