author | Claus Gittinger <cg@exept.de> |
Mon, 08 Feb 2016 10:05:00 +0100 | |
changeset 5586 | 0f8333c00ca4 |
parent 5553 | f684e07a633d |
child 5699 | 1ebb2d421c0d |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1990 by Claus Gittinger |
59 | 3 |
All Rights Reserved |
0 | 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 |
" |
|
2261
260a8cd9905d
added a selectionChanged callback
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
12 |
"{ Package: 'stx:libwidg' }" |
260a8cd9905d
added a selectionChanged callback
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
13 |
|
5553 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
0 | 16 |
EnterBox subclass:#ListSelectionBox |
4407 | 17 |
instanceVariableNames:'panel list selectionList selectionChangeCallback useIndex |
5553 | 18 |
searchJob clearEntryFieldOnDeselect' |
371 | 19 |
classVariableNames:'' |
20 |
poolDictionaries:'' |
|
21 |
category:'Views-DialogBoxes' |
|
0 | 22 |
! |
23 |
||
1273 | 24 |
!ListSelectionBox class methodsFor:'documentation'! |
38 | 25 |
|
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 1990 by Claus Gittinger |
|
59 | 29 |
All Rights Reserved |
38 | 30 |
|
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
0 | 39 |
|
38 | 40 |
documentation |
41 |
" |
|
42 |
this class implements boxes for selection from a list. It offers |
|
43 |
both an ok- and abort-buttons. The ok-button, if pressed will |
|
44 |
evaluate the okAction (see EnterBox>>action). |
|
77 | 45 |
see examples for typical uses. |
46 |
||
47 |
Notice, for file selections there is a specialized FileSelectionBox, |
|
48 |
which supports matchPatterns, changing directory etc. |
|
585 | 49 |
|
50 |
[author:] |
|
51 |
Claus Gittinger |
|
77 | 52 |
" |
53 |
! |
|
54 |
||
55 |
examples |
|
56 |
" |
|
57 |
simple: |
|
593 | 58 |
[exBegin] |
59 |
|box| |
|
38 | 60 |
|
593 | 61 |
box := ListSelectionBox new. |
62 |
box title:'select something:'. |
|
63 |
box list:#('foo' 'bar' 'baz'). |
|
2543 | 64 |
box okAction:[:sel | Transcript show:'the selection was:' ; showCR:sel]. |
593 | 65 |
box showAtPointer |
66 |
[exEnd] |
|
77 | 67 |
|
2541 | 68 |
with index (instead of list-entry) and without an enterField: |
69 |
[exBegin] |
|
70 |
|box| |
|
71 |
||
72 |
box := ListSelectionBox new. |
|
73 |
box title:'select something:'. |
|
74 |
box list:#('foo' 'bar' 'baz'). |
|
75 |
box useIndex:true. |
|
76 |
box okAction:[:sel | Transcript show:'the selection was:' ; showCR:sel]. |
|
77 |
box showAtPointer |
|
78 |
[exEnd] |
|
79 |
||
155 | 80 |
|
77 | 81 |
with a default: |
593 | 82 |
[exBegin] |
83 |
|box| |
|
77 | 84 |
|
593 | 85 |
box := ListSelectionBox new. |
86 |
box title:'select something:'. |
|
87 |
box list:#('foo' 'bar' 'baz'). |
|
2543 | 88 |
box okAction:[:sel | Transcript show:'the selection was:' ; showCR:sel]. |
593 | 89 |
box initialText:'foo'. |
90 |
box showAtPointer |
|
91 |
[exEnd] |
|
155 | 92 |
|
93 |
||
94 |
opening the box modeless (a stand-by box): |
|
95 |
(in this case, the default ok- and abortActions do not hide the box; |
|
96 |
therefore, we have to set those explicitely) |
|
593 | 97 |
[exBegin] |
98 |
|box| |
|
155 | 99 |
|
593 | 100 |
box := ListSelectionBox new. |
101 |
box title:'select something:'. |
|
102 |
box list:#('foo' 'bar' 'baz'). |
|
103 |
box abortText:'close'. |
|
104 |
box okText:'apply'. |
|
2543 | 105 |
box okAction:[:sel | Transcript show:'the selection was:' ; showCR:sel]. |
593 | 106 |
box abortAction:[:dummy | box hide]. |
107 |
box openModeless |
|
108 |
[exEnd] |
|
2280
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
109 |
|
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
110 |
showing fileNames: |
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
111 |
[exBegin] |
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
112 |
|box| |
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
113 |
|
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
114 |
box := ListSelectionBox new. |
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
115 |
box title:'select something:'. |
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
116 |
box list:('.' asFilename directoryContents). |
2543 | 117 |
box okAction:[:sel | Transcript show:'the selection was:' ; showCR:sel]. |
2280
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
118 |
box showAtPointer |
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
119 |
[exEnd] |
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
120 |
|
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
121 |
|
38 | 122 |
" |
197 | 123 |
! ! |
124 |
||
1273 | 125 |
!ListSelectionBox class methodsFor:'instance creation'! |
197 | 126 |
|
127 |
title:titleString okText:okText abortText:abortText list:aList action:aBlock |
|
128 |
"create and return a new listSelectionBox with list already defined" |
|
129 |
||
130 |
|newBox| |
|
131 |
||
2543 | 132 |
newBox := self |
133 |
title:titleString okText:okText abortText:abortText |
|
134 |
action:aBlock. |
|
135 |
newBox list:aList. |
|
136 |
^ newBox |
|
38 | 137 |
! ! |
0 | 138 |
|
1273 | 139 |
!ListSelectionBox class methodsFor:'defaults'! |
0 | 140 |
|
141 |
defaultExtent |
|
571 | 142 |
"return the default extent of my instances. |
143 |
The value returned here is usually ignored, and |
|
144 |
the value from preferredExtent taken instead." |
|
145 |
||
775
ccc53ba319bc
dont ask Display for defaultExtent - ask current screen
Claus Gittinger <cg@exept.de>
parents:
740
diff
changeset
|
146 |
^ (Screen current pixelPerMillimeter * (80 @ 100)) rounded |
571 | 147 |
|
775
ccc53ba319bc
dont ask Display for defaultExtent - ask current screen
Claus Gittinger <cg@exept.de>
parents:
740
diff
changeset
|
148 |
"Modified: 5.7.1996 / 13:53:46 / cg" |
12 | 149 |
! |
150 |
||
151 |
listViewType |
|
152 |
"return the type of listView |
|
153 |
- for easier redefinition in subclasses" |
|
154 |
||
155 |
^ SelectionInListView |
|
0 | 156 |
! ! |
157 |
||
197 | 158 |
!ListSelectionBox methodsFor:'accessing'! |
159 |
||
402
ed4a635f43c6
oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
160 |
contents |
ed4a635f43c6
oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
161 |
"return my contents" |
ed4a635f43c6
oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
162 |
|
ed4a635f43c6
oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
163 |
enterField isNil ifTrue:[ |
ed4a635f43c6
oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
164 |
^ selectionList selectionValue |
ed4a635f43c6
oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
165 |
]. |
ed4a635f43c6
oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
166 |
^ super contents |
ed4a635f43c6
oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
167 |
|
ed4a635f43c6
oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
168 |
"Created: 26.2.1996 / 20:05:47 / cg" |
ed4a635f43c6
oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
169 |
! |
ed4a635f43c6
oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
170 |
|
3048 | 171 |
initialSelection:selected |
172 |
"select some item in the list" |
|
173 |
||
174 |
||
175 |
selectionList selection:selected |
|
176 |
! |
|
177 |
||
2444 | 178 |
initialText:someString selected:selected |
179 |
"in addition to showing the initial text; optionally also select it in the list" |
|
0 | 180 |
|
2444 | 181 |
super initialText:someString selected:selected. |
182 |
selected ifTrue:[ |
|
183 |
selectionList setSelectElement:someString |
|
184 |
]. |
|
690 | 185 |
|
186 |
"Modified: 26.5.1996 / 15:03:37 / cg" |
|
197 | 187 |
! |
188 |
||
189 |
list:aList |
|
190 |
"set the list to be displayed in selection list" |
|
191 |
||
4298
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
192 |
list := aList. |
197 | 193 |
selectionList list:aList |
4298
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
194 |
|
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
195 |
"Modified: / 03-08-2011 / 12:30:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
841 | 196 |
! |
197 |
||
2261
260a8cd9905d
added a selectionChanged callback
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
198 |
selectionChangeCallback:aBlock |
2359 | 199 |
"allows special actions to be hooked in, when the selection changes" |
2261
260a8cd9905d
added a selectionChanged callback
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
200 |
|
260a8cd9905d
added a selectionChanged callback
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
201 |
selectionChangeCallback := aBlock. |
260a8cd9905d
added a selectionChanged callback
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
202 |
! |
260a8cd9905d
added a selectionChanged callback
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
203 |
|
841 | 204 |
selectionIndex |
205 |
^ selectionList selection |
|
206 |
||
207 |
"Created: 14.10.1996 / 16:28:50 / cg" |
|
2958 | 208 |
! |
209 |
||
210 |
selectionList |
|
211 |
||
212 |
^selectionList |
|
2546 | 213 |
! ! |
214 |
||
215 |
!ListSelectionBox methodsFor:'accessing-behavior'! |
|
2541 | 216 |
|
5553 | 217 |
clearEntryFieldOnDeselect |
218 |
"normally, the entryfield's contents is not cleared, |
|
219 |
when the list is deselected. |
|
220 |
This can be changed here." |
|
221 |
||
222 |
^ clearEntryFieldOnDeselect ? false |
|
223 |
! |
|
224 |
||
225 |
clearEntryFieldOnDeselect:aBoolean |
|
226 |
"normally, the entryfield's contents is not cleared, |
|
227 |
when the list is deselected. |
|
228 |
This can be changed here." |
|
229 |
||
230 |
clearEntryFieldOnDeselect := aBoolean. |
|
231 |
! |
|
232 |
||
2541 | 233 |
useIndex:aBoolean |
234 |
aBoolean ifTrue:[ |
|
235 |
self noEnterField |
|
236 |
]. |
|
2545 | 237 |
useIndex := aBoolean |
197 | 238 |
! ! |
0 | 239 |
|
197 | 240 |
!ListSelectionBox methodsFor:'accessing-components'! |
241 |
||
242 |
listView |
|
243 |
"return the listView component" |
|
244 |
||
245 |
^ selectionList |
|
0 | 246 |
|
197 | 247 |
"Created: 26.10.1995 / 17:08:32 / cg" |
4407 | 248 |
! |
249 |
||
250 |
panelView |
|
251 |
^ panel |
|
252 |
||
253 |
"Created: / 22-03-2012 / 10:30:16 / cg" |
|
197 | 254 |
! ! |
255 |
||
256 |
!ListSelectionBox methodsFor:'accessing-look'! |
|
257 |
||
258 |
noEnterField |
|
638 | 259 |
"suppress the enterField - now only existing items are selectable; |
260 |
the default is to present an enterField." |
|
261 |
||
197 | 262 |
enterField destroy. |
263 |
enterField := nil |
|
264 |
||
265 |
"Created: 26.10.1995 / 17:12:38 / cg" |
|
638 | 266 |
"Modified: 12.5.1996 / 21:49:14 / cg" |
2556 | 267 |
! |
268 |
||
269 |
useComboBoxWithList:list |
|
270 |
"change the enterField to be a ComboList" |
|
271 |
||
272 |
self addEnterField:(ComboBoxView new). |
|
273 |
enterField leaveAction:[:key | self okPressed]. |
|
274 |
enterField list:list. |
|
0 | 275 |
! ! |
276 |
||
277 |
!ListSelectionBox methodsFor:'initialization'! |
|
278 |
||
4298
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
279 |
beLiveSearchBox |
5222 | 280 |
#todo. "/ Jan, please comment what it does and who needs it |
4298
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
281 |
|
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
282 |
enterField delegate:( |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
283 |
KeyboardForwarder |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
284 |
toView:selectionList |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
285 |
condition:[:type :key :view|(key == #CursorUp) or:[key == #CursorDown]] |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
286 |
filter:[:key | (key == #CursorUp) or:[key == #CursorDown]] |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
287 |
). |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
288 |
|
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
289 |
searchJob := BackgroundJob |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
290 |
named: 'List Selection Box Search Job' |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
291 |
on: [self filterList]. |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
292 |
|
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
293 |
enterField immediateAccept: true. |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
294 |
enterField model: ValueHolder new. |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
295 |
enterField model onChangeSend: #restart to: searchJob. |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
296 |
|
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
297 |
"Created: / 03-08-2011 / 12:27:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
298 |
! |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
299 |
|
0 | 300 |
initialize |
1281 | 301 |
|space2 halfSpace v vbw| |
0 | 302 |
|
303 |
super initialize. |
|
304 |
||
2545 | 305 |
useIndex := false. |
4166 | 306 |
"/ label := resources string:'Select or Enter'. |
307 |
label := resources string:'Please Select'. |
|
77 | 308 |
|
0 | 309 |
"need more space than an enterBox" |
310 |
||
311 |
"self height:(height + (font height * 5)). " |
|
312 |
||
313 |
space2 := 2 * ViewSpacing. |
|
125 | 314 |
halfSpace := ViewSpacing // 2. |
0 | 315 |
|
4407 | 316 |
panel := VerticalPanelView in:self. |
317 |
panel horizontalLayout:#fit. |
|
318 |
panel verticalLayout:#topFit. |
|
319 |
||
320 |
v := HVScrollableView for:(self class listViewType) in:panel. |
|
2295 | 321 |
v horizontalScrollable:true; horizontalMini:true; autoHideHorizontalScrollBar:true. |
0 | 322 |
|
132 | 323 |
"/ old: |
324 |
"/ v origin:[0.0 |
|
125 | 325 |
"/ @ |
132 | 326 |
"/ (enterField origin y + enterField height + ViewSpacing)] |
327 |
"/ extent:[1.0 |
|
125 | 328 |
"/ @ |
132 | 329 |
"/ (height |
125 | 330 |
"/ - ViewSpacing - labelField heightIncludingBorder |
331 |
"/ - ViewSpacing - enterField heightIncludingBorder |
|
332 |
"/ - buttonPanel heightIncludingBorder - ViewSpacing |
|
333 |
"/ - space2) |
|
132 | 334 |
"/ ]. |
335 |
||
336 |
"/ new: |
|
4407 | 337 |
panel origin:[enterField notNil ifTrue:[ |
412 | 338 |
0.0 @ (enterField origin y + enterField height + ViewSpacing) |
339 |
] ifFalse:[ |
|
340 |
0.0 @ (labelField origin y + labelField height + ViewSpacing) |
|
341 |
] |
|
342 |
] |
|
132 | 343 |
corner:(1.0 @ 1.0). |
4407 | 344 |
panel bottomInset:(buttonPanel preferredHeight + ViewSpacing). |
132 | 345 |
|
139 | 346 |
vbw := v borderWidth. |
4407 | 347 |
v |
348 |
leftInset:halfSpace+vbw; |
|
349 |
rightInset:halfSpace+vbw. |
|
110 | 350 |
|
0 | 351 |
selectionList := v scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
724
diff
changeset
|
352 |
self makeTabable:selectionList. |
0 | 353 |
|
354 |
"self updateList." |
|
355 |
||
724 | 356 |
"I am interested in what is done in the selectionList |
132 | 357 |
(could also create a SelectionInList-model and catch its changes ...)" |
358 |
selectionList action:[:lineNr | self selectionChanged]. |
|
359 |
selectionList doubleClickAction:[:lineNr | self doubleClick]. |
|
360 |
||
2511
639be3067ff8
suppress focus from going to listView.
Claus Gittinger <cg@exept.de>
parents:
2500
diff
changeset
|
361 |
selectionList doNotRequestFocusOnPointerEnter:true. |
639be3067ff8
suppress focus from going to listView.
Claus Gittinger <cg@exept.de>
parents:
2500
diff
changeset
|
362 |
|
5586 | 363 |
enterField removeDependent:self. "don't want preferredExtent-changes" |
128 | 364 |
|
2280
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
365 |
enterField immediateAccept:true. |
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
366 |
enterField acceptAction: |
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
367 |
[:text | |string index| |
2282 | 368 |
enterField notNil ifTrue:[ |
369 |
string := enterField contents. |
|
370 |
"/ find the first list-entry, starting with entered text |
|
4088 | 371 |
index := (selectionList list ? #()) findFirst:[:line | (line ? '') string startsWith:string string]. |
2282 | 372 |
index ~~ 0 ifTrue:[ |
2659
abd630c5a9fc
scrollToLine instead of makeLineVisible
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
373 |
selectionList scrollToLine:index "/ makeLineVisible:index. |
2282 | 374 |
]. |
2280
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
375 |
]. |
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
376 |
]. |
d9ee8906706e
scroll to make the typed-in string visible in the list (if present)
Claus Gittinger <cg@exept.de>
parents:
2261
diff
changeset
|
377 |
|
38 | 378 |
" |
379 |
mhm: the lists keyboard functions are disabled, |
|
319
d78f5fbdee27
dont forward Cursor-motion to the enterField
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
380 |
and input passed to the enterfield (except cursor keys) |
38 | 381 |
" |
319
d78f5fbdee27
dont forward Cursor-motion to the enterField
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
382 |
selectionList delegate:( |
412 | 383 |
KeyboardForwarder |
384 |
toView:enterField |
|
385 |
condition:#noFocus |
|
386 |
filter:[:key | (key ~~ #CursorUp) and:[key ~~ #CursorDown]] |
|
387 |
) |
|
166 | 388 |
|
4407 | 389 |
"Modified (format): / 22-03-2012 / 10:30:03 / cg" |
0 | 390 |
! |
391 |
||
1273 | 392 |
postRealize |
393 |
"update the list now. |
|
638 | 394 |
This was not done in #initialize to allow settings to be changed before, |
395 |
in case list-updating is a slow operation - such as reading a directory" |
|
396 |
||
1273 | 397 |
super postRealize. |
0 | 398 |
self updateList. |
638 | 399 |
|
400 |
"Modified: 12.5.1996 / 21:50:50 / cg" |
|
1273 | 401 |
"Created: 24.7.1997 / 18:22:19 / cg" |
77 | 402 |
! |
403 |
||
197 | 404 |
updateList |
638 | 405 |
"setup contents of list; |
406 |
nothing done here but typically redefined in subclasses." |
|
197 | 407 |
|
408 |
^ self |
|
638 | 409 |
|
410 |
"Modified: 12.5.1996 / 21:51:10 / cg" |
|
0 | 411 |
! ! |
412 |
||
4298
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
413 |
!ListSelectionBox methodsFor:'private'! |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
414 |
|
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
415 |
filterList |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
416 |
|
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
417 |
| pattern filteredList | |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
418 |
|
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
419 |
pattern := enterField model value. |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
420 |
pattern isEmptyOrNil ifTrue:[ |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
421 |
filteredList := list. |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
422 |
] ifFalse:[ |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
423 |
filteredList := list select:[:each|each asString startsWith: pattern]. |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
424 |
]. |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
425 |
self sensor pushUserEvent: #list: for: selectionList withArgument: filteredList |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
426 |
|
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
427 |
"Created: / 03-08-2011 / 12:27:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
428 |
! ! |
331907254f82
added live-search support
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4166
diff
changeset
|
429 |
|
59 | 430 |
!ListSelectionBox methodsFor:'queries'! |
0 | 431 |
|
130 | 432 |
preferredExtent |
433 |
"return my preferred extent - thats the minimum size |
|
125 | 434 |
I like to have, to make everything visible" |
0 | 435 |
|
2500
fc1ee2b3fa81
ListSelectionBox is at least as wide as its buttonPanel.
Stefan Vogel <sv@exept.de>
parents:
2444
diff
changeset
|
436 |
|wWanted hWanted eH mm bw| |
371 | 437 |
|
3759
0318021891be
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
438 |
"/ If I have an explicit preferredExtent.. |
0318021891be
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
439 |
explicitExtent notNil ifTrue:[ |
0318021891be
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
440 |
^ explicitExtent |
0318021891be
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
441 |
]. |
799 | 442 |
|
3759
0318021891be
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
443 |
"/ If I have a cached preferredExtent value.. |
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
444 |
preferredExtent notNil ifTrue:[ |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
445 |
^ preferredExtent |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
446 |
]. |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
447 |
|
371 | 448 |
mm := ViewSpacing. |
125 | 449 |
|
371 | 450 |
wWanted := mm + labelField width + mm. |
0 | 451 |
(wWanted > width) ifFalse:[ |
371 | 452 |
wWanted := width |
0 | 453 |
]. |
3611
a1654baf3f37
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3048
diff
changeset
|
454 |
bw := buttonPanel preferredWidth. |
2500
fc1ee2b3fa81
ListSelectionBox is at least as wide as its buttonPanel.
Stefan Vogel <sv@exept.de>
parents:
2444
diff
changeset
|
455 |
bw > wWanted ifTrue:[ |
fc1ee2b3fa81
ListSelectionBox is at least as wide as its buttonPanel.
Stefan Vogel <sv@exept.de>
parents:
2444
diff
changeset
|
456 |
wWanted := bw. |
fc1ee2b3fa81
ListSelectionBox is at least as wide as its buttonPanel.
Stefan Vogel <sv@exept.de>
parents:
2444
diff
changeset
|
457 |
]. |
125 | 458 |
|
166 | 459 |
enterField notNil ifTrue:[ |
371 | 460 |
eH := enterField height + mm |
166 | 461 |
] ifFalse:[ |
371 | 462 |
eH := 0 |
166 | 463 |
]. |
371 | 464 |
hWanted := mm + labelField height + |
465 |
eH + |
|
466 |
mm + selectionList height + |
|
3611
a1654baf3f37
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3048
diff
changeset
|
467 |
mm + buttonPanel preferredHeight + |
371 | 468 |
mm - (mm * 2). |
0 | 469 |
|
470 |
(hWanted < height) ifTrue:[ |
|
371 | 471 |
hWanted := height |
0 | 472 |
]. |
59 | 473 |
^ (wWanted @ hWanted) |
166 | 474 |
|
799 | 475 |
"Modified: 19.7.1996 / 20:44:52 / cg" |
0 | 476 |
! ! |
477 |
||
132 | 478 |
!ListSelectionBox methodsFor:'user actions'! |
479 |
||
2541 | 480 |
actionArgument |
2545 | 481 |
useIndex ifTrue:[ |
2541 | 482 |
^self selectionIndex. |
483 |
]. |
|
484 |
^ super actionArgument |
|
485 |
! |
|
486 |
||
197 | 487 |
doubleClick |
488 |
"doubleClick on an entry is select & ok" |
|
489 |
||
402
ed4a635f43c6
oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
490 |
enterField notNil ifTrue:[ |
ed4a635f43c6
oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
491 |
enterField contents:(selectionList selectionValue). |
ed4a635f43c6
oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
492 |
]. |
197 | 493 |
self okPressed |
402
ed4a635f43c6
oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
494 |
|
ed4a635f43c6
oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
495 |
"Modified: 26.2.1996 / 20:05:45 / cg" |
197 | 496 |
! |
497 |
||
132 | 498 |
selectionChanged |
499 |
"selections in list get forwarded to enterfield" |
|
500 |
||
166 | 501 |
enterField notNil ifTrue:[ |
5553 | 502 |
|val| |
503 |
||
504 |
val := selectionList selectionValue. |
|
505 |
(val notEmptyOrNil or:[self clearEntryFieldOnDeselect]) ifTrue:[ |
|
506 |
enterField contents:val |
|
507 |
]. |
|
2261
260a8cd9905d
added a selectionChanged callback
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
508 |
]. |
260a8cd9905d
added a selectionChanged callback
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
509 |
selectionChangeCallback notNil ifTrue:[ |
260a8cd9905d
added a selectionChanged callback
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
510 |
selectionChangeCallback value:selectionList selection |
260a8cd9905d
added a selectionChanged callback
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
511 |
]. |
166 | 512 |
|
513 |
"Modified: 26.10.1995 / 17:20:06 / cg" |
|
514 |
! ! |
|
515 |
||
1273 | 516 |
!ListSelectionBox class methodsFor:'documentation'! |
243 | 517 |
|
518 |
version |
|
5553 | 519 |
^ '$Header$' |
4088 | 520 |
! |
521 |
||
522 |
version_CVS |
|
5553 | 523 |
^ '$Header$' |
243 | 524 |
! ! |
5222 | 525 |