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