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