author | Claus Gittinger <cg@exept.de> |
Fri, 28 Feb 1997 14:02:31 +0100 | |
changeset 311 | d790d0524822 |
parent 305 | 7dd100869f7b |
child 332 | 78dcd3cacbfd |
permissions | -rw-r--r-- |
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
1 |
ComboView subclass:#ComboBoxView |
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
2 |
instanceVariableNames:'' |
124 | 3 |
classVariableNames:'' |
4 |
poolDictionaries:'' |
|
5 |
category:'Views-Interactors' |
|
6 |
! |
|
7 |
||
275 | 8 |
!ComboBoxView class methodsFor:'documentation'! |
124 | 9 |
|
10 |
documentation |
|
11 |
" |
|
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
12 |
A ComboBoxView combines an inputField with a drop down list of default inputs; |
126
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
13 |
choosing any from the pulled list presets the string in the field. |
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
14 |
|
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
15 |
In contrast to a PopUpList or ComboListView, the string can still be edited - |
126
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
16 |
the list is actually only a set of values for the convenience of the user. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
17 |
|
275 | 18 |
Not yet finished - it may need more protocol. |
19 |
||
20 |
[author:] |
|
21 |
Claus Gittinger |
|
181 | 22 |
|
23 |
[see also:] |
|
275 | 24 |
ComboView |
25 |
PopUpList SelectionInListView |
|
181 | 26 |
ComboListView |
275 | 27 |
PullDownMenu Label EntryField |
124 | 28 |
" |
29 |
! |
|
30 |
||
31 |
examples |
|
32 |
" |
|
305 | 33 |
non MVC operation: |
181 | 34 |
[exBegin] |
124 | 35 |
|top b| |
36 |
||
37 |
top := StandardSystemView new. |
|
38 |
top extent:(300 @ 200). |
|
39 |
||
40 |
b := ComboBoxView in:top. |
|
41 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
42 |
b bottomInset:(b preferredExtent y negated). |
|
43 |
||
44 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
45 |
top open. |
|
181 | 46 |
[exEnd] |
124 | 47 |
|
48 |
||
49 |
||
305 | 50 |
with action: |
51 |
[exBegin] |
|
52 |
|top b| |
|
53 |
||
54 |
top := StandardSystemView new. |
|
55 |
top extent:(300 @ 200). |
|
56 |
||
57 |
b := ComboBoxView in:top. |
|
58 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
59 |
b bottomInset:(b preferredExtent y negated). |
|
60 |
||
61 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
62 |
b action:[:entry | Transcript showCR:entry]. |
|
63 |
top open. |
|
64 |
[exEnd] |
|
65 |
||
66 |
||
67 |
||
124 | 68 |
model operation: |
181 | 69 |
[exBegin] |
124 | 70 |
|model top b| |
71 |
||
72 |
model := 'foo' asValue. |
|
73 |
||
74 |
top := StandardSystemView new. |
|
75 |
top extent:(300 @ 200). |
|
76 |
||
77 |
b := ComboBoxView in:top. |
|
78 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
79 |
b bottomInset:(b preferredExtent y negated). |
|
80 |
||
81 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
82 |
b model:model. |
|
83 |
||
84 |
top openModal. |
|
184 | 85 |
Transcript showCR:('comboBox''s value: ' , model value). |
181 | 86 |
[exEnd] |
126
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
87 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
88 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
89 |
in a dialog: |
181 | 90 |
[exBegin] |
126
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
91 |
|model1 model2 dialog b| |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
92 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
93 |
model1 := 'foo' asValue. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
94 |
model2 := 'bar' asValue. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
95 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
96 |
dialog := Dialog new. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
97 |
(dialog addTextLabel:'ComboBox example:') adjust:#left. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
98 |
dialog addVerticalSpace. |
124 | 99 |
|
126
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
100 |
(b := dialog addComboBoxOn:model1 tabable:true). |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
101 |
b list:#('fee' 'foe' 'foo'). |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
102 |
dialog addVerticalSpace. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
103 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
104 |
(b := dialog addComboBoxOn:model2 tabable:true). |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
105 |
b list:#('bar' 'baz' 'baloo'). |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
106 |
dialog addVerticalSpace. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
107 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
108 |
dialog addOkButton. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
109 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
110 |
dialog open. |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
111 |
|
184 | 112 |
Transcript showCR:('1st comboBox''s value: ' , model1 value). |
113 |
Transcript showCR:('2nd comboBox''s value: ' , model2 value). |
|
181 | 114 |
[exEnd] |
124 | 115 |
" |
116 |
! ! |
|
117 |
||
126
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
118 |
!ComboBoxView methodsFor:'accessing-components'! |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
119 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
120 |
editor |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
121 |
"return the inputField component" |
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
122 |
|
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
123 |
^ field |
126
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
124 |
|
888d8ccd35af
better sizing; forward unknown messages to my inputField
Claus Gittinger <cg@exept.de>
parents:
125
diff
changeset
|
125 |
"Created: 9.2.1996 / 20:18:03 / cg" |
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
126 |
"Modified: 28.2.1996 / 15:10:50 / cg" |
124 | 127 |
! ! |
128 |
||
129 |
!ComboBoxView methodsFor:'accessing-mvc'! |
|
130 |
||
135 | 131 |
accept |
132 |
field accept |
|
133 |
||
134 |
"Created: 4.3.1996 / 12:15:18 / cg" |
|
135 |
! |
|
136 |
||
124 | 137 |
model |
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
138 |
^ field model |
124 | 139 |
|
140 |
"Created: 9.2.1996 / 00:50:18 / cg" |
|
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
141 |
"Modified: 28.2.1996 / 15:10:59 / cg" |
124 | 142 |
! |
143 |
||
144 |
model:aModel |
|
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
145 |
field model:aModel. |
124 | 146 |
|
147 |
"Created: 9.2.1996 / 00:50:12 / cg" |
|
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
148 |
"Modified: 28.2.1996 / 15:11:03 / cg" |
124 | 149 |
! ! |
150 |
||
151 |
!ComboBoxView methodsFor:'initialization'! |
|
152 |
||
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
153 |
initializeField |
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
154 |
field := EditField in:self. |
279 | 155 |
field model:(ValueHolder newString). |
305 | 156 |
field acceptOnLostFocus:true. |
157 |
field acceptOnLeave:true. |
|
158 |
field leaveAction:[:key | self fieldLeft]. |
|
124 | 159 |
|
160 |
" |
|
161 |
all of my input goes to the enterfield |
|
162 |
" |
|
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
163 |
self delegate:(KeyboardForwarder toView:field). |
124 | 164 |
|
165 |
" |
|
166 |
|b| |
|
167 |
||
168 |
b := ComboBoxView new. |
|
169 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
170 |
b open |
|
171 |
" |
|
172 |
||
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
173 |
"Created: 28.2.1996 / 15:07:51 / cg" |
305 | 174 |
"Modified: 26.2.1997 / 19:44:13 / cg" |
124 | 175 |
! ! |
176 |
||
291 | 177 |
!ComboBoxView methodsFor:'queries'! |
178 |
||
179 |
specClass |
|
180 |
self class == ComboBoxView ifTrue:[ |
|
181 |
^ ComboBoxSpec |
|
182 |
]. |
|
301 | 183 |
^ super specClass |
184 |
||
291 | 185 |
! ! |
186 |
||
124 | 187 |
!ComboBoxView methodsFor:'user interaction'! |
188 |
||
311 | 189 |
fieldLeft |
190 |
field accept. |
|
191 |
||
192 |
action notNil ifTrue:[ |
|
193 |
action value:(field contents) |
|
194 |
]. |
|
195 |
||
196 |
"Modified: 26.2.1997 / 19:38:24 / cg" |
|
197 |
"Created: 26.2.1997 / 19:42:30 / cg" |
|
198 |
! |
|
199 |
||
200 |
select:index |
|
230 | 201 |
|what| |
202 |
||
203 |
what := list at:index. |
|
130
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
204 |
field contents:what. |
5cad43b11fb5
inserted abstract ComboView class
Claus Gittinger <cg@exept.de>
parents:
127
diff
changeset
|
205 |
field accept. |
124 | 206 |
pullDownButton turnOff. |
207 |
||
305 | 208 |
action notNil ifTrue:[ |
209 |
action value:what |
|
210 |
]. |
|
211 |
||
212 |
"Modified: 26.2.1997 / 19:38:24 / cg" |
|
311 | 213 |
"Created: 28.2.1997 / 14:01:53 / cg" |
124 | 214 |
! ! |
215 |
||
275 | 216 |
!ComboBoxView class methodsFor:'documentation'! |
124 | 217 |
|
218 |
version |
|
311 | 219 |
^ '$Header: /cvs/stx/stx/libwidg2/ComboBoxView.st,v 1.15 1997-02-28 13:02:31 cg Exp $' |
124 | 220 |
! ! |