3792
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
3700
|
3 |
"{ Package: 'stx:libtool2' }"
|
|
4 |
|
|
5 |
"{ NameSpace: Smalltalk }"
|
|
6 |
|
|
7 |
Object subclass:#ShowMeHowItWorks
|
3783
|
8 |
instanceVariableNames:'application opStream streamStack lastComponentName lastComponent
|
|
9 |
lastResult voice translate language verifying
|
3784
|
10 |
closeApplicationWhenFinished defaultComponentWaitTime ui'
|
3790
|
11 |
classVariableNames:'IntroShownCount DebugMode StartLabel'
|
3700
|
12 |
poolDictionaries:''
|
|
13 |
category:'Interface-Help'
|
|
14 |
!
|
|
15 |
|
|
16 |
!ShowMeHowItWorks class methodsFor:'documentation'!
|
|
17 |
|
|
18 |
documentation
|
|
19 |
"
|
3713
|
20 |
automatic presentations.
|
|
21 |
To see how it works, open a methodFinder:
|
|
22 |
MethodFinderWindow open
|
|
23 |
and select its 'Show me how it works' item in the help menu.
|
3700
|
24 |
|
|
25 |
[author:]
|
|
26 |
Claus Gittinger
|
|
27 |
"
|
|
28 |
!
|
|
29 |
|
|
30 |
example
|
3713
|
31 |
MethodFinderWindow open.
|
|
32 |
|
3700
|
33 |
ShowMeHowItWorks do:#(
|
|
34 |
( showing: 'Choose the number of arguments' do:(
|
|
35 |
moveTo: NumberOfArguments
|
|
36 |
select: '1'
|
|
37 |
))
|
|
38 |
(showing: 'Click into the "receiver" field' do:(
|
|
39 |
moveTo: ReceiverEditor
|
|
40 |
click: ReceiverEditor
|
|
41 |
))
|
|
42 |
(showing: 'Enter a value (or expression) into "receiver" field' do:(
|
|
43 |
enter: '100'
|
|
44 |
))
|
|
45 |
(showing: 'Click into the "first argument" field' do:(
|
|
46 |
moveTo: Arg1Editor
|
|
47 |
click: ReceiverEditor
|
|
48 |
))
|
|
49 |
(showing: 'Enter a value (or expression) into "receiver" field' do:(
|
|
50 |
enter: '100'
|
|
51 |
))
|
|
52 |
|
|
53 |
)
|
|
54 |
! !
|
|
55 |
|
|
56 |
!ShowMeHowItWorks class methodsFor:'running'!
|
|
57 |
|
3775
|
58 |
application:anApplicationOrNilForAll do:specArray
|
|
59 |
"spec contains a list of action commands (show: / moveTo: etc.)"
|
|
60 |
|
|
61 |
self new
|
|
62 |
application:anApplicationOrNilForAll;
|
|
63 |
do:specArray
|
|
64 |
|
|
65 |
"
|
|
66 |
ShowMeHowItWorks do:
|
|
67 |
#(
|
|
68 |
(language: de)
|
3792
|
69 |
(show: 'üben üben üben')
|
3775
|
70 |
(wait: 0.5)
|
|
71 |
(moveTo: NameOfComponent)
|
|
72 |
)
|
|
73 |
"
|
|
74 |
|
|
75 |
"Created: / 19-07-2019 / 10:52:59 / Claus Gittinger"
|
|
76 |
"Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger"
|
|
77 |
!
|
|
78 |
|
3700
|
79 |
do:specArray
|
3728
|
80 |
"spec contains a list of action commands (show: / moveTo: etc.)"
|
3727
|
81 |
|
3784
|
82 |
self do:specArray withUI:false
|
3700
|
83 |
|
3727
|
84 |
"
|
|
85 |
ShowMeHowItWorks do:
|
|
86 |
#(
|
3728
|
87 |
(language: de)
|
3792
|
88 |
(show: 'üben üben üben')
|
3728
|
89 |
(wait: 0.5)
|
3727
|
90 |
(moveTo: NameOfComponent)
|
|
91 |
)
|
|
92 |
"
|
|
93 |
|
|
94 |
"Created: / 19-07-2019 / 10:52:59 / Claus Gittinger"
|
3728
|
95 |
"Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger"
|
3784
|
96 |
!
|
|
97 |
|
3787
|
98 |
do:specArray from:startLabelOrNil withUI:withUIBoolean
|
|
99 |
"spec contains a list of action commands (show: / moveTo: etc.)"
|
|
100 |
|
|
101 |
self new
|
|
102 |
do:specArray
|
|
103 |
from:startLabelOrNil
|
|
104 |
withUI:withUIBoolean
|
|
105 |
|
|
106 |
"
|
|
107 |
ShowMeHowItWorks
|
|
108 |
do:#(
|
|
109 |
(language: de)
|
3792
|
110 |
(show: 'üben üben üben')
|
3787
|
111 |
(wait: 0.5)
|
|
112 |
(moveTo: NameOfComponent)
|
|
113 |
)
|
|
114 |
withUI:true
|
|
115 |
"
|
|
116 |
|
|
117 |
"Created: / 19-07-2019 / 10:52:59 / Claus Gittinger"
|
|
118 |
"Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger"
|
|
119 |
!
|
|
120 |
|
3784
|
121 |
do:specArray withUI:withUIBoolean
|
|
122 |
"spec contains a list of action commands (show: / moveTo: etc.)"
|
|
123 |
|
|
124 |
self new do:specArray withUI:withUIBoolean
|
|
125 |
|
|
126 |
"
|
|
127 |
ShowMeHowItWorks
|
|
128 |
do:#(
|
|
129 |
(language: de)
|
3792
|
130 |
(show: 'üben üben üben')
|
3784
|
131 |
(wait: 0.5)
|
|
132 |
(moveTo: NameOfComponent)
|
|
133 |
)
|
|
134 |
withUI:true
|
|
135 |
"
|
|
136 |
|
|
137 |
"Created: / 19-07-2019 / 10:52:59 / Claus Gittinger"
|
|
138 |
"Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger"
|
3713
|
139 |
! !
|
|
140 |
|
|
141 |
!ShowMeHowItWorks methodsFor:'accessing'!
|
|
142 |
|
3775
|
143 |
application:anApplication
|
|
144 |
"if set, only that application is presented (widget search is limtied to that one)"
|
|
145 |
|
|
146 |
application := anApplication.
|
3700
|
147 |
! !
|
|
148 |
|
|
149 |
!ShowMeHowItWorks methodsFor:'commands'!
|
|
150 |
|
3711
|
151 |
intro
|
|
152 |
<action>
|
3724
|
153 |
|
3775
|
154 |
verifying ifTrue:[^ self].
|
|
155 |
|
|
156 |
IntroShownCount := (IntroShownCount ? 0).
|
|
157 |
|
3728
|
158 |
"/ only say this a few times..
|
|
159 |
IntroShownCount > 3 ifTrue:[^ self].
|
3775
|
160 |
IntroShownCount := IntroShownCount + 1.
|
|
161 |
|
|
162 |
self language:(Smalltalk language).
|
3724
|
163 |
self tell:(self class classResources
|
3733
|
164 |
string:'You can stop this show, by pressing the SHIFT key').
|
3711
|
165 |
|
|
166 |
"Created: / 19-07-2019 / 15:49:19 / Claus Gittinger"
|
3733
|
167 |
"Modified: / 23-07-2019 / 11:06:13 / Claus Gittinger"
|
3728
|
168 |
!
|
|
169 |
|
3787
|
170 |
label:nameOfLabel
|
|
171 |
<action>
|
|
172 |
|
|
173 |
"/ skipped here; see goto
|
|
174 |
!
|
|
175 |
|
3728
|
176 |
language:lang
|
|
177 |
<action>
|
|
178 |
|
|
179 |
voice := OperatingSystem bestVoiceForLanguage:lang.
|
|
180 |
translate := false.
|
3775
|
181 |
language := lang.
|
3728
|
182 |
|
|
183 |
"Created: / 23-07-2019 / 10:27:02 / Claus Gittinger"
|
3711
|
184 |
!
|
|
185 |
|
3780
|
186 |
open:applicationClassName
|
|
187 |
<action>
|
|
188 |
|
|
189 |
|appClass|
|
|
190 |
|
|
191 |
(appClass := Smalltalk classNamed:applicationClassName) isNil ifTrue:[
|
|
192 |
self error:'no such application class'
|
|
193 |
].
|
|
194 |
verifying ifFalse:[
|
|
195 |
application := appClass new openAndWaitUntilVisible.
|
|
196 |
closeApplicationWhenFinished := true.
|
|
197 |
].
|
|
198 |
|
|
199 |
"Created: / 19-07-2019 / 15:09:45 / Claus Gittinger"
|
|
200 |
!
|
|
201 |
|
3700
|
202 |
pause
|
|
203 |
<action>
|
|
204 |
|
3724
|
205 |
Dialog information:(self class classResources
|
|
206 |
stringWithCRs:'Show Paused.\Click on "OK" to proceed')
|
3700
|
207 |
|
|
208 |
"Created: / 19-07-2019 / 15:03:17 / Claus Gittinger"
|
3711
|
209 |
"Modified: / 19-07-2019 / 16:13:33 / Claus Gittinger"
|
3700
|
210 |
!
|
|
211 |
|
3776
|
212 |
raise:what
|
|
213 |
<action>
|
|
214 |
|
|
215 |
verifying ifTrue:[^ self].
|
|
216 |
|
|
217 |
what == #application ifTrue:[
|
|
218 |
application topView raise.
|
|
219 |
^ self
|
|
220 |
].
|
|
221 |
what == #masterApplication ifTrue:[
|
|
222 |
application windowGroup isModal ifTrue:[
|
|
223 |
application windowGroup mainGroup topViews first raise
|
|
224 |
] ifFalse:[
|
|
225 |
(application masterApplication ? application) topViews first raise.
|
|
226 |
].
|
|
227 |
^ self
|
|
228 |
].
|
|
229 |
self halt.
|
|
230 |
!
|
|
231 |
|
3711
|
232 |
show:message
|
3714
|
233 |
"showing (and speak) some message."
|
3711
|
234 |
|
|
235 |
<action>
|
|
236 |
|
3776
|
237 |
self showing:message saying:nil do:nil
|
3711
|
238 |
|
|
239 |
"Created: / 19-07-2019 / 15:59:18 / Claus Gittinger"
|
3714
|
240 |
"Modified (comment): / 19-07-2019 / 18:54:36 / Claus Gittinger"
|
|
241 |
!
|
|
242 |
|
|
243 |
show:message for:seconds
|
|
244 |
"showing (and speak) some message and wait for some time."
|
|
245 |
|
|
246 |
<action>
|
3780
|
247 |
|
|
248 |
DebugMode == true ifTrue:[^ self].
|
|
249 |
|
3714
|
250 |
self show:message.
|
|
251 |
self wait:seconds.
|
|
252 |
|
|
253 |
"Created: / 19-07-2019 / 18:54:20 / Claus Gittinger"
|
3711
|
254 |
!
|
|
255 |
|
3776
|
256 |
show:message saying:sentenceOrNil
|
|
257 |
"showing (and speak) some message."
|
|
258 |
|
|
259 |
<action>
|
|
260 |
|
|
261 |
self showing:message saying:sentenceOrNil do:nil
|
|
262 |
|
|
263 |
"Created: / 19-07-2019 / 15:59:18 / Claus Gittinger"
|
|
264 |
"Modified (comment): / 19-07-2019 / 18:54:36 / Claus Gittinger"
|
|
265 |
!
|
|
266 |
|
|
267 |
show:message saying:sentenceOrNil for:seconds
|
|
268 |
"showing (and speak) some message and wait for some time."
|
|
269 |
|
|
270 |
<action>
|
|
271 |
|
3780
|
272 |
DebugMode == true ifTrue:[^ self].
|
3776
|
273 |
self show:message saying:sentenceOrNil.
|
|
274 |
self wait:seconds.
|
|
275 |
|
|
276 |
"Created: / 19-07-2019 / 18:54:20 / Claus Gittinger"
|
|
277 |
!
|
|
278 |
|
3711
|
279 |
showing:message do:operationsOrNothing
|
3714
|
280 |
"execute operationsOrNothing while showing (and speaking) some message."
|
3700
|
281 |
|
|
282 |
<action>
|
|
283 |
|
3776
|
284 |
self showing:message saying:nil do:operationsOrNothing
|
|
285 |
!
|
|
286 |
|
|
287 |
showing:message saying:sentenceOrNil do:operationsOrNothing
|
|
288 |
"execute operationsOrNothing while showing (and speaking) some message."
|
|
289 |
|
|
290 |
<action>
|
|
291 |
|
3715
|
292 |
|xLatedMessage messageView talkDone|
|
3700
|
293 |
|
3728
|
294 |
xLatedMessage := (translate and:[application notNil])
|
|
295 |
ifTrue:[application resources string:message]
|
|
296 |
ifFalse:[message].
|
|
297 |
|
3711
|
298 |
self assert:(operationsOrNothing isNil or:[operationsOrNothing isSequenceable]).
|
3700
|
299 |
|
3715
|
300 |
messageView := ActiveHelpView for:xLatedMessage.
|
3700
|
301 |
"/ messageView shapeStyle:#cartoon.
|
|
302 |
[
|
3780
|
303 |
messageView origin:(Screen current pointerPosition + (0 @ 20)).
|
|
304 |
messageView makeFullyVisible.
|
3700
|
305 |
messageView realize.
|
|
306 |
|
|
307 |
self talking ifTrue:[
|
|
308 |
talkDone := Semaphore new.
|
|
309 |
[
|
3776
|
310 |
self tell:(sentenceOrNil ? xLatedMessage).
|
3700
|
311 |
talkDone signal
|
|
312 |
] fork.
|
|
313 |
|
|
314 |
"/
|
|
315 |
"/ allow speaker some headoff
|
3775
|
316 |
verifying ifFalse:[
|
|
317 |
Delay waitForSeconds:(xLatedMessage size / 15)+0.5.
|
|
318 |
].
|
3700
|
319 |
].
|
|
320 |
|
3711
|
321 |
operationsOrNothing notEmptyOrNil ifTrue:[
|
|
322 |
self doStream:(operationsOrNothing readStream).
|
|
323 |
].
|
3700
|
324 |
] ensure:[
|
|
325 |
messageView destroy
|
|
326 |
].
|
|
327 |
self talking ifTrue:[
|
|
328 |
talkDone wait.
|
|
329 |
].
|
|
330 |
|
|
331 |
"Created: / 19-07-2019 / 11:19:27 / Claus Gittinger"
|
3728
|
332 |
"Modified: / 23-07-2019 / 10:52:30 / Claus Gittinger"
|
|
333 |
!
|
|
334 |
|
|
335 |
thankyou
|
|
336 |
<action>
|
|
337 |
|
|
338 |
self show:(self randomThankYou).
|
|
339 |
|
|
340 |
"Created: / 23-07-2019 / 10:50:43 / Claus Gittinger"
|
3700
|
341 |
!
|
|
342 |
|
|
343 |
wait:seconds
|
|
344 |
<action>
|
|
345 |
|
3775
|
346 |
verifying ifTrue:[^ self].
|
3780
|
347 |
DebugMode == true ifTrue:[^ self].
|
3776
|
348 |
Display ctrlDown ifTrue:[^ self].
|
|
349 |
|
3700
|
350 |
Delay waitForSeconds:seconds
|
|
351 |
|
|
352 |
"Created: / 19-07-2019 / 15:09:45 / Claus Gittinger"
|
3780
|
353 |
!
|
|
354 |
|
|
355 |
waitFor:componentName timeout:seconds
|
|
356 |
<action>
|
|
357 |
|
|
358 |
|endTime|
|
|
359 |
|
3781
|
360 |
verifying ifTrue:[^ self].
|
|
361 |
|
3780
|
362 |
endTime := Timestamp now + seconds.
|
3787
|
363 |
[
|
|
364 |
(self findComponent:componentName inAllApplications:true ifMultiple:nil) notNil ifTrue:[
|
3780
|
365 |
^ self
|
|
366 |
].
|
|
367 |
Delay waitForSeconds:0.05.
|
|
368 |
Timestamp now > endTime ifTrue:[
|
|
369 |
self error:('component %1 not present after %2' bindWith:componentName with:seconds)
|
|
370 |
]
|
|
371 |
] loop
|
3700
|
372 |
! !
|
|
373 |
|
3711
|
374 |
!ShowMeHowItWorks methodsFor:'commands - checking'!
|
|
375 |
|
|
376 |
isEmpty:componentName
|
|
377 |
<action>
|
|
378 |
|
|
379 |
|component|
|
|
380 |
|
|
381 |
component := self componentNamed:componentName.
|
|
382 |
component isScrollWrapper ifTrue:[ component := component scrolledView ].
|
|
383 |
component isTextView ifTrue:[
|
|
384 |
^ component contents isEmptyOrNil
|
|
385 |
] ifFalse:[
|
|
386 |
self halt.
|
|
387 |
].
|
|
388 |
self error:'isEmpty: unhandled component type: ',component displayString.
|
|
389 |
|
|
390 |
"Created: / 19-07-2019 / 15:33:47 / Claus Gittinger"
|
|
391 |
!
|
|
392 |
|
|
393 |
unless:query do:actions
|
|
394 |
<action>
|
|
395 |
|
|
396 |
|result|
|
|
397 |
|
|
398 |
result := self doCommand:query.
|
|
399 |
result ifFalse:[
|
|
400 |
self doCommand:actions
|
|
401 |
].
|
|
402 |
|
|
403 |
"Created: / 19-07-2019 / 15:33:32 / Claus Gittinger"
|
|
404 |
! !
|
|
405 |
|
|
406 |
!ShowMeHowItWorks methodsFor:'commands - mouse & keyboard'!
|
|
407 |
|
|
408 |
click
|
|
409 |
"press-release"
|
|
410 |
|
|
411 |
<action>
|
|
412 |
|
|
413 |
^ self click:1 inComponent:lastComponent
|
|
414 |
|
|
415 |
"Created: / 19-07-2019 / 16:11:03 / Claus Gittinger"
|
|
416 |
!
|
3700
|
417 |
|
|
418 |
click:buttonNr
|
|
419 |
"press-release"
|
|
420 |
|
|
421 |
<action>
|
|
422 |
|
3711
|
423 |
self assert:(buttonNr isInteger).
|
|
424 |
^ self click:buttonNr inComponent:lastComponent
|
3700
|
425 |
|
|
426 |
"Created: / 19-07-2019 / 13:21:20 / Claus Gittinger"
|
3711
|
427 |
"Modified: / 19-07-2019 / 16:10:19 / Claus Gittinger"
|
3700
|
428 |
!
|
|
429 |
|
3711
|
430 |
clickIn:componentName
|
|
431 |
"press-release"
|
|
432 |
|
|
433 |
<action>
|
|
434 |
|
|
435 |
^ self click:1 inComponent:(self componentNamed:componentName)
|
|
436 |
|
|
437 |
"Created: / 19-07-2019 / 16:09:58 / Claus Gittinger"
|
|
438 |
!
|
|
439 |
|
3787
|
440 |
drag:itemsIndexOrLabelOrPattern toComponent:targetComponentName dropAt:where
|
|
441 |
"drag an item (by index or label) from the current treeView,
|
|
442 |
into another component.
|
|
443 |
where is one of: #top, #center or #bottom.
|
|
444 |
allowed after moving to:
|
|
445 |
aSelectionInHierarchyView
|
|
446 |
"
|
|
447 |
|
|
448 |
<action>
|
|
449 |
|
3790
|
450 |
self drag:itemsIndexOrLabelOrPattern toComponent:targetComponentName dropAt:where show:nil
|
|
451 |
!
|
|
452 |
|
|
453 |
drag:itemsIndexOrLabelOrPattern toComponent:targetComponentName dropAt:where show:textWhenDroppingOrNil
|
|
454 |
"drag an item (by index or label) from the current treeView,
|
|
455 |
into another component.
|
|
456 |
where is one of: #top, #center or #bottom.
|
|
457 |
allowed after moving to:
|
|
458 |
aSelectionInHierarchyView
|
|
459 |
"
|
|
460 |
|
|
461 |
<action>
|
|
462 |
|
3787
|
463 |
|sourceComponent targetComponent idx yPos sourcePos sourcePosOnScreen
|
3790
|
464 |
targetPos targetPosOnScreen targetPosInSource dNdMgr|
|
3787
|
465 |
|
|
466 |
verifying ifTrue:[^ self].
|
|
467 |
|
|
468 |
targetComponent := self findComponent:targetComponentName.
|
|
469 |
self assert:targetComponent notNil.
|
|
470 |
|
|
471 |
((sourceComponent := lastComponent) isKindOf:ScrollableView) ifTrue:[
|
|
472 |
sourceComponent := sourceComponent scrolledView.
|
|
473 |
].
|
|
474 |
|
3790
|
475 |
where == #topLeft ifTrue:[
|
|
476 |
targetPos := targetComponent topLeft + (1@1).
|
|
477 |
] ifFalse:[
|
|
478 |
where == #topCenter ifTrue:[
|
3791
|
479 |
targetPos := targetComponent topCenter + (0@5).
|
3787
|
480 |
] ifFalse:[
|
|
481 |
where == #center ifTrue:[
|
|
482 |
targetPos := targetComponent center
|
|
483 |
] ifFalse:[
|
3790
|
484 |
where == #bottomCenter ifTrue:[
|
3791
|
485 |
targetPos := targetComponent bottomCenter - (0 @ 5)
|
3790
|
486 |
] ifFalse:[
|
|
487 |
where == #bottomLeft ifTrue:[
|
3791
|
488 |
targetPos := targetComponent bottomLeft + (1 @ -5)
|
3790
|
489 |
] ifFalse:[
|
|
490 |
self error:'where is this'
|
|
491 |
].
|
3787
|
492 |
].
|
|
493 |
].
|
|
494 |
].
|
3790
|
495 |
].
|
|
496 |
|
|
497 |
(sourceComponent isKindOf:HierarchicalListView) ifTrue:[
|
3787
|
498 |
|
|
499 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[
|
|
500 |
idx := itemsIndexOrLabelOrPattern
|
|
501 |
] ifFalse:[
|
|
502 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
|
|
503 |
idx := sourceComponent indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string].
|
|
504 |
] ifFalse:[
|
|
505 |
idx := sourceComponent indexOfElementForWhich:[:el | el label string = itemsIndexOrLabelOrPattern].
|
|
506 |
].
|
|
507 |
idx == 0 ifTrue:[
|
|
508 |
self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern
|
|
509 |
].
|
|
510 |
].
|
|
511 |
yPos := sourceComponent yVisibleOfLine:idx.
|
|
512 |
self movePointerToComponent:sourceComponent rightOffset:(10 @ (yPos + 3)).
|
|
513 |
Delay waitForSeconds:0.5.
|
|
514 |
sourcePosOnScreen := Display pointerPosition.
|
|
515 |
sourcePos := Display translatePoint:sourcePosOnScreen from:nil to:sourceComponent.
|
|
516 |
|
|
517 |
targetPosOnScreen := Display translatePoint:targetPos from:targetComponent to:nil.
|
|
518 |
targetPosInSource := Display translatePoint:targetPosOnScreen from:nil to:sourceComponent.
|
|
519 |
|
|
520 |
sourceComponent simulateButtonPress:1 at:sourcePos sendDisplayEvent:true.
|
3790
|
521 |
dNdMgr := sourceComponent startDragAt:sourcePos.
|
|
522 |
|
|
523 |
textWhenDroppingOrNil notNil ifTrue:[
|
|
524 |
self show:textWhenDroppingOrNil.
|
|
525 |
].
|
|
526 |
|
|
527 |
Delay waitForSeconds:1.
|
3787
|
528 |
self movePointerToComponent:targetComponent offset:targetPos.
|
3790
|
529 |
Delay waitForSeconds:1.
|
|
530 |
dNdMgr buttonMotion:1 x:targetPos x y:targetPos y view:targetComponent.
|
3787
|
531 |
|
3790
|
532 |
sourceComponent simulateButtonRelease:1 at:targetPos sendDisplayEvent:true.
|
|
533 |
dNdMgr buttonRelease:1 x:targetPos x y:targetPos y view:targetComponent.
|
3787
|
534 |
^ self
|
|
535 |
].
|
|
536 |
|
|
537 |
self error:'cannot expand in this component'
|
|
538 |
|
|
539 |
"Created: / 19-07-2019 / 12:34:25 / Claus Gittinger"
|
|
540 |
"Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger"
|
|
541 |
!
|
|
542 |
|
|
543 |
expand:itemsIndexOrLabelOrPattern
|
|
544 |
"expand an item in a treeView by label,
|
|
545 |
allowed after moving to:
|
|
546 |
aSelectionInHierarchyView
|
|
547 |
"
|
|
548 |
|
|
549 |
<action>
|
|
550 |
|
|
551 |
|component|
|
|
552 |
|
|
553 |
verifying ifTrue:[^ self].
|
|
554 |
|
|
555 |
((component := lastComponent) isKindOf:ScrollableView) ifTrue:[
|
|
556 |
component := component scrolledView.
|
|
557 |
].
|
|
558 |
|
|
559 |
(component isKindOf:HierarchicalListView) ifTrue:[
|
|
560 |
|idx yPos|
|
|
561 |
|
|
562 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[
|
|
563 |
idx := itemsIndexOrLabelOrPattern
|
|
564 |
] ifFalse:[
|
|
565 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
|
|
566 |
idx := component indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string].
|
|
567 |
] ifFalse:[
|
|
568 |
idx := component indexOfElementForWhich:[:el | el label string = itemsIndexOrLabelOrPattern].
|
|
569 |
].
|
|
570 |
idx == 0 ifTrue:[
|
|
571 |
self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern
|
|
572 |
].
|
|
573 |
].
|
|
574 |
yPos := component yVisibleOfLine:idx.
|
|
575 |
self movePointerToComponent:component offset:(0 @ (yPos + 3)).
|
|
576 |
Delay waitForSeconds:0.5.
|
|
577 |
(component listAt:idx) expand.
|
|
578 |
^ self
|
|
579 |
].
|
|
580 |
|
|
581 |
self error:'cannot expand in this component'
|
|
582 |
|
|
583 |
"Created: / 19-07-2019 / 12:34:25 / Claus Gittinger"
|
|
584 |
"Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger"
|
|
585 |
!
|
|
586 |
|
3711
|
587 |
fastMoveTo:componentName
|
|
588 |
"move the mouse to componentName without circling"
|
3700
|
589 |
|
|
590 |
<action>
|
|
591 |
|
3711
|
592 |
|component|
|
3700
|
593 |
|
3711
|
594 |
component := self componentNamed:componentName.
|
3717
|
595 |
self movePointerToComponent:component speed:(self pointerMoveSpeedFast).
|
3711
|
596 |
|
3727
|
597 |
"
|
|
598 |
ShowMeHowItWorks basicNew fastMoveTo:'Classes'
|
|
599 |
ShowMeHowItWorks basicNew fastMoveTo:'Klassen'
|
|
600 |
"
|
|
601 |
|
3711
|
602 |
"Created: / 19-07-2019 / 15:39:23 / Claus Gittinger"
|
3717
|
603 |
"Modified: / 20-07-2019 / 08:14:16 / Claus Gittinger"
|
3727
|
604 |
"Modified (comment): / 23-07-2019 / 09:33:31 / Claus Gittinger"
|
3700
|
605 |
!
|
|
606 |
|
|
607 |
moveTo:componentName
|
|
608 |
"move the mouse to componentName,
|
|
609 |
then circle around it a few times"
|
|
610 |
|
|
611 |
<action>
|
|
612 |
|
|
613 |
|component|
|
|
614 |
|
3711
|
615 |
component := self componentNamed:componentName.
|
3700
|
616 |
self movePointerToComponent:component.
|
3776
|
617 |
Display ctrlDown ifTrue:[^ self].
|
3700
|
618 |
self circlePointerAroundComponent:component.
|
|
619 |
|
|
620 |
"Created: / 19-07-2019 / 11:20:42 / Claus Gittinger"
|
3711
|
621 |
"Modified: / 19-07-2019 / 15:38:11 / Claus Gittinger"
|
3700
|
622 |
!
|
|
623 |
|
3787
|
624 |
select:itemsIndexOrLabelOrPattern
|
3700
|
625 |
"select an item by label,
|
|
626 |
allowed after moving to:
|
|
627 |
aComboBox
|
|
628 |
aSelectionInListView
|
|
629 |
"
|
|
630 |
|
|
631 |
<action>
|
|
632 |
|
3783
|
633 |
|idx component|
|
3775
|
634 |
|
|
635 |
verifying ifTrue:[^ self].
|
|
636 |
|
3783
|
637 |
((component := lastComponent) isKindOf:ScrollableView) ifTrue:[
|
|
638 |
component := component scrolledView.
|
|
639 |
].
|
|
640 |
|
|
641 |
(component isKindOf:ComboView) ifTrue:[
|
3700
|
642 |
"/ click on the menubutton
|
3783
|
643 |
self movePointerToComponent:component menuButton.
|
|
644 |
self click:1 inComponent:component menuButton.
|
3700
|
645 |
Delay waitForSeconds:0.3.
|
3787
|
646 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[
|
|
647 |
idx := itemsIndexOrLabelOrPattern
|
|
648 |
] ifFalse:[
|
|
649 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
|
|
650 |
idx := component list findFirst:[:lbl | itemsIndexOrLabelOrPattern match:lbl]
|
|
651 |
] ifFalse:[
|
|
652 |
idx := component list indexOf:itemsIndexOrLabelOrPattern.
|
|
653 |
].
|
|
654 |
idx == 0 ifTrue:[
|
|
655 |
self error:'no such item in comboList: ',itemsIndexOrLabelOrPattern
|
|
656 |
].
|
3700
|
657 |
].
|
3783
|
658 |
component select:idx.
|
3700
|
659 |
Delay waitForSeconds:0.3.
|
3783
|
660 |
component shownMenu notNil ifTrue:[
|
|
661 |
component shownMenu hide.
|
3700
|
662 |
].
|
|
663 |
^ self
|
|
664 |
].
|
3783
|
665 |
(component isKindOf:HierarchicalListView) ifTrue:[
|
3787
|
666 |
|idx yPos|
|
|
667 |
|
|
668 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[
|
|
669 |
idx := itemsIndexOrLabelOrPattern
|
|
670 |
] ifFalse:[
|
|
671 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
|
|
672 |
idx := component indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string].
|
|
673 |
] ifFalse:[
|
|
674 |
idx := component indexOfElementForWhich:[:el | el label string = itemsIndexOrLabelOrPattern].
|
3783
|
675 |
].
|
3787
|
676 |
idx == 0 ifTrue:[
|
|
677 |
self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern
|
|
678 |
].
|
|
679 |
].
|
|
680 |
yPos := component yVisibleOfLine:idx.
|
|
681 |
self movePointerToComponent:component offset:(0 @ (yPos + 3)).
|
|
682 |
component simulateButtonPress:1 at:(0 @ (yPos + 3)) sendDisplayEvent:false.
|
|
683 |
Delay waitForSeconds:0.1.
|
|
684 |
component simulateButtonRelease:1 at:(0 @ (yPos + 3)) sendDisplayEvent:false.
|
|
685 |
"/ component selection:idx.
|
3783
|
686 |
^ self
|
|
687 |
].
|
|
688 |
|
3700
|
689 |
self error:'cannot select this component'
|
|
690 |
|
|
691 |
"Created: / 19-07-2019 / 12:34:25 / Claus Gittinger"
|
|
692 |
"Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger"
|
|
693 |
!
|
|
694 |
|
|
695 |
selectIndex:itemsIndex
|
|
696 |
"select an item by index,
|
|
697 |
allowed after moving to:
|
|
698 |
aComboBox
|
|
699 |
aSelectionInListView
|
|
700 |
"
|
|
701 |
|
|
702 |
<action>
|
|
703 |
|
3716
|
704 |
self selectIndex:itemsIndex in:lastComponent
|
|
705 |
|
|
706 |
"Created: / 19-07-2019 / 14:20:11 / Claus Gittinger"
|
|
707 |
"Modified: / 19-07-2019 / 21:59:36 / Claus Gittinger"
|
|
708 |
!
|
3711
|
709 |
|
3716
|
710 |
selectIndex:itemsIndex in:widgetArg
|
|
711 |
"select an item by index,
|
|
712 |
allowed after moving to:
|
|
713 |
aComboBox
|
|
714 |
aSelectionInListView
|
|
715 |
"
|
|
716 |
|
|
717 |
<action>
|
|
718 |
|
|
719 |
|widget y offset possibleWidgets|
|
|
720 |
|
3775
|
721 |
verifying ifTrue:[^ self].
|
|
722 |
|
3716
|
723 |
(widget := widgetArg) isScrollWrapper ifTrue:[
|
3711
|
724 |
widget := widget scrolledView
|
|
725 |
].
|
|
726 |
|
|
727 |
(widget isKindOf:ComboView) ifTrue:[
|
3700
|
728 |
"/ click on the menubutton
|
3711
|
729 |
self movePointerToComponent:widget menuButton.
|
|
730 |
self click:1 inComponent:widget menuButton.
|
3700
|
731 |
Delay waitForSeconds:0.5.
|
3711
|
732 |
widget select:itemsIndex.
|
3700
|
733 |
Delay waitForSeconds:0.5.
|
|
734 |
^ self
|
|
735 |
].
|
3711
|
736 |
(widget isKindOf:SelectionInListView) ifTrue:[
|
3716
|
737 |
(widget isLineVisible:itemsIndex) ifFalse:[
|
|
738 |
widget scrollToLine:itemsIndex
|
|
739 |
].
|
3711
|
740 |
"/ click on the item
|
|
741 |
y := widget yOfLine:itemsIndex.
|
|
742 |
offset := (widget width // 2) @ y.
|
|
743 |
self movePointerToComponent:widget offset:offset.
|
|
744 |
widget simulateButtonPress:1 at:offset sendDisplayEvent:false.
|
|
745 |
Delay waitForSeconds:(self clickTime).
|
|
746 |
widget simulateButtonRelease:1 at:offset sendDisplayEvent:false.
|
|
747 |
Delay waitForSeconds:0.5.
|
|
748 |
^ self
|
3716
|
749 |
].
|
|
750 |
(widget isKindOf:SelectionInListModelView) ifTrue:[
|
|
751 |
(widget isLineVisible:itemsIndex) ifFalse:[
|
|
752 |
widget scrollToLine:itemsIndex
|
|
753 |
].
|
|
754 |
y := widget yVisibleOfLine:itemsIndex.
|
|
755 |
offset := (widget width // 2) @ y.
|
|
756 |
self movePointerToComponent:widget offset:offset.
|
|
757 |
widget simulateButtonPress:1 at:offset sendDisplayEvent:false.
|
|
758 |
Delay waitForSeconds:(self clickTime).
|
|
759 |
widget simulateButtonRelease:1 at:offset sendDisplayEvent:false.
|
|
760 |
Delay waitForSeconds:0.5.
|
|
761 |
^ self
|
|
762 |
].
|
|
763 |
|
|
764 |
"/ none of it - see what is in there
|
|
765 |
possibleWidgets := OrderedCollection new.
|
|
766 |
widget allSubViewsDo:[:each |
|
|
767 |
((each isKindOf:ComboView)
|
|
768 |
or:[(each isKindOf:SelectionInListView)
|
|
769 |
or:[(each isKindOf:SelectionInListModelView)
|
|
770 |
]]) ifTrue:[
|
|
771 |
possibleWidgets add:each
|
|
772 |
]
|
|
773 |
].
|
|
774 |
possibleWidgets size == 1 ifTrue:[
|
|
775 |
self selectIndex:itemsIndex in:(possibleWidgets first).
|
|
776 |
^ self
|
3711
|
777 |
].
|
3716
|
778 |
|
3700
|
779 |
self error:'cannot select this component'
|
|
780 |
|
3716
|
781 |
"Created: / 19-07-2019 / 21:59:15 / Claus Gittinger"
|
|
782 |
"Modified: / 20-07-2019 / 07:57:41 / Claus Gittinger"
|
3711
|
783 |
!
|
|
784 |
|
|
785 |
type:aString
|
|
786 |
"enter text into the last component"
|
|
787 |
|
|
788 |
<action>
|
|
789 |
|
3776
|
790 |
|t|
|
|
791 |
|
3775
|
792 |
verifying ifTrue:[^ self].
|
|
793 |
|
3776
|
794 |
t := Display ctrlDown ifTrue:[0.05] ifFalse:[0.1].
|
|
795 |
lastComponent
|
|
796 |
simulateTextInput:aString at:(lastComponent extent // 2)
|
|
797 |
sendDisplayEvent:false keyPressTime:t
|
3711
|
798 |
|
|
799 |
"Created: / 19-07-2019 / 15:50:40 / Claus Gittinger"
|
3700
|
800 |
! !
|
|
801 |
|
|
802 |
!ShowMeHowItWorks methodsFor:'defaults'!
|
|
803 |
|
|
804 |
circlingCount
|
|
805 |
"circle around move-end position that many times"
|
|
806 |
|
|
807 |
^ 3
|
|
808 |
|
|
809 |
"Created: / 19-07-2019 / 13:03:45 / Claus Gittinger"
|
|
810 |
!
|
|
811 |
|
|
812 |
circlingRadius
|
|
813 |
"radius when circling"
|
|
814 |
|
|
815 |
^ 30 "/ pixels
|
|
816 |
|
|
817 |
"Created: / 19-07-2019 / 13:07:59 / Claus Gittinger"
|
|
818 |
!
|
|
819 |
|
|
820 |
circlingSpeed
|
|
821 |
"time per round when circling"
|
|
822 |
|
|
823 |
^ 0.3 seconds. "/ time per round
|
|
824 |
|
|
825 |
"Created: / 19-07-2019 / 13:02:34 / Claus Gittinger"
|
|
826 |
!
|
|
827 |
|
|
828 |
clickTime
|
|
829 |
"when clicking"
|
|
830 |
|
3711
|
831 |
^ self shortClickTime
|
3700
|
832 |
|
|
833 |
"Created: / 19-07-2019 / 13:17:20 / Claus Gittinger"
|
3711
|
834 |
"Modified: / 19-07-2019 / 15:21:51 / Claus Gittinger"
|
|
835 |
!
|
|
836 |
|
|
837 |
longClickTime
|
|
838 |
"when clicking buttons"
|
|
839 |
|
|
840 |
^ 500 milliseconds
|
|
841 |
|
|
842 |
"Created: / 19-07-2019 / 15:21:42 / Claus Gittinger"
|
3700
|
843 |
!
|
|
844 |
|
|
845 |
pointerAnimationDelay
|
|
846 |
^ 50 milliseconds. "/ 20 updates per second
|
|
847 |
|
|
848 |
"Created: / 19-07-2019 / 13:04:45 / Claus Gittinger"
|
|
849 |
!
|
|
850 |
|
|
851 |
pointerMoveSpeed
|
|
852 |
^ 400. "/ pixels per second
|
|
853 |
|
|
854 |
"Created: / 19-07-2019 / 13:05:40 / Claus Gittinger"
|
|
855 |
!
|
|
856 |
|
3717
|
857 |
pointerMoveSpeedFast
|
|
858 |
^ 600. "/ pixels per second
|
|
859 |
|
|
860 |
"Created: / 20-07-2019 / 08:13:58 / Claus Gittinger"
|
|
861 |
!
|
|
862 |
|
3711
|
863 |
shortClickTime
|
|
864 |
"when clicking"
|
|
865 |
|
|
866 |
^ 100 milliseconds
|
|
867 |
|
|
868 |
"Created: / 19-07-2019 / 15:21:29 / Claus Gittinger"
|
|
869 |
!
|
|
870 |
|
3700
|
871 |
talking
|
3780
|
872 |
"/ DebugMode := true
|
3775
|
873 |
verifying ifTrue:[^ false].
|
3780
|
874 |
DebugMode == true ifTrue:[^ false].
|
3775
|
875 |
|
3727
|
876 |
"/ ^ Expecco::ExpeccoPreferences current speechEffectsEnabled
|
3700
|
877 |
^ true
|
|
878 |
|
|
879 |
"Created: / 19-07-2019 / 14:31:14 / Claus Gittinger"
|
3727
|
880 |
"Modified (comment): / 23-07-2019 / 09:45:35 / Claus Gittinger"
|
3700
|
881 |
! !
|
|
882 |
|
|
883 |
!ShowMeHowItWorks methodsFor:'helper'!
|
|
884 |
|
3715
|
885 |
randomThankYou
|
|
886 |
^ #(
|
|
887 |
'thank you, for watching'
|
|
888 |
'thank you for watching'
|
|
889 |
'thank you'
|
3775
|
890 |
'thanks'
|
3715
|
891 |
'have a good day'
|
3775
|
892 |
'have a nice day'
|
3715
|
893 |
'have fun'
|
|
894 |
'have fun with expecco'
|
|
895 |
'have fun with expecco, by the way: expecco comes from the latin word: peccare, which means: "to sin"'
|
|
896 |
'happy hacking'
|
|
897 |
'happy hacking, I hope you liked what you saw'
|
|
898 |
'hope you liked it'
|
|
899 |
'see you again'
|
3775
|
900 |
'be the source with you'
|
|
901 |
'be the force with you'
|
|
902 |
'may the force be with you'
|
|
903 |
'may the source be with you'
|
3715
|
904 |
'please give feedback, and let us know, if you liked it'
|
|
905 |
'if you have any questions, please contact exept'
|
|
906 |
'if you need more information, please take a look at the wiki'
|
|
907 |
) atRandom
|
|
908 |
|
|
909 |
"
|
3775
|
910 |
OperatingSystem speak:'may the source be with you'
|
3715
|
911 |
OperatingSystem speak:'have fun with expecco'
|
3716
|
912 |
OperatingSystem speak:'have fun with expecco, by the way: expecco comes from the latin word: peccare, which means: to sin'
|
3715
|
913 |
OperatingSystem speak:'happy hacking, I hope you liked what you saw'
|
|
914 |
OperatingSystem speak:'please give feedback, and let us know, if you liked it'
|
|
915 |
OperatingSystem speak:'if you have any questions, please contact exept'
|
|
916 |
OperatingSystem speak:'if you need more information, please take a look at the wiki'
|
|
917 |
"
|
|
918 |
|
|
919 |
"Created: / 19-07-2019 / 21:39:18 / Claus Gittinger"
|
|
920 |
!
|
|
921 |
|
3700
|
922 |
tell:message
|
|
923 |
self talking ifTrue:[
|
3728
|
924 |
OperatingSystem speak:message voiceName:voice.
|
3700
|
925 |
].
|
|
926 |
|
|
927 |
"Created: / 19-07-2019 / 14:57:50 / Claus Gittinger"
|
3728
|
928 |
"Modified: / 23-07-2019 / 10:28:02 / Claus Gittinger"
|
3700
|
929 |
! !
|
|
930 |
|
|
931 |
!ShowMeHowItWorks methodsFor:'helpers - broken'!
|
|
932 |
|
|
933 |
click:buttonNr atPosition:position
|
|
934 |
"press-release at position"
|
|
935 |
|
|
936 |
|screen|
|
|
937 |
|
3775
|
938 |
verifying ifTrue:[^ self].
|
|
939 |
|
3700
|
940 |
screen := Screen current.
|
|
941 |
|
|
942 |
screen setPointerPosition:position.
|
|
943 |
screen flush.
|
|
944 |
self click:buttonNr
|
|
945 |
|
|
946 |
"Created: / 19-07-2019 / 13:14:51 / Claus Gittinger"
|
|
947 |
! !
|
|
948 |
|
3727
|
949 |
!ShowMeHowItWorks methodsFor:'helpers - component search'!
|
|
950 |
|
|
951 |
componentNamed:componentName
|
|
952 |
"retrieve a component by name or report an error if not found.
|
|
953 |
Can return either a view or a menu item"
|
|
954 |
|
|
955 |
|component|
|
|
956 |
|
|
957 |
lastComponentName := componentName.
|
|
958 |
|
|
959 |
component := self findComponent:componentName.
|
|
960 |
component isNil ifTrue:[
|
3784
|
961 |
self error:'no component found for: ',componentName mayProceed:verifying.
|
|
962 |
^ nil
|
3727
|
963 |
].
|
|
964 |
lastComponent := component.
|
|
965 |
^ component
|
|
966 |
|
|
967 |
"Created: / 19-07-2019 / 15:37:35 / Claus Gittinger"
|
|
968 |
"Modified (comment): / 23-07-2019 / 09:31:53 / Claus Gittinger"
|
|
969 |
!
|
|
970 |
|
|
971 |
findComponent:componentName
|
|
972 |
"find a component by name - in the active and possibly in any app.
|
|
973 |
Can return either a view or a menu item"
|
|
974 |
|
3787
|
975 |
^ self
|
|
976 |
findComponent:componentName
|
|
977 |
inAllApplications:true
|
|
978 |
ifMultiple:[
|
|
979 |
self proceedableError:('multiple components found by name: ',componentName).
|
|
980 |
nil
|
3727
|
981 |
].
|
3780
|
982 |
|
3787
|
983 |
"
|
|
984 |
ShowMeHowItWorks basicNew findComponent:'Classes'
|
|
985 |
ShowMeHowItWorks basicNew findComponent:'Klassen'
|
|
986 |
"
|
3780
|
987 |
|
3787
|
988 |
"Created: / 19-07-2019 / 12:02:30 / Claus Gittinger"
|
|
989 |
"Modified: / 19-07-2019 / 16:44:30 / Claus Gittinger"
|
|
990 |
"Modified (comment): / 23-07-2019 / 09:32:44 / Claus Gittinger"
|
|
991 |
!
|
|
992 |
|
|
993 |
findComponent:componentName ifMultiple:exceptionalValue
|
|
994 |
"find a component by name - in the active and possibly in any app.
|
|
995 |
Can return either a view or a menu item"
|
|
996 |
|
|
997 |
^ self
|
|
998 |
findComponent:componentName
|
|
999 |
inAllApplications:true
|
|
1000 |
ifMultiple:exceptionalValue
|
3727
|
1001 |
|
|
1002 |
"
|
|
1003 |
ShowMeHowItWorks basicNew findComponent:'Classes'
|
|
1004 |
ShowMeHowItWorks basicNew findComponent:'Klassen'
|
|
1005 |
"
|
|
1006 |
|
|
1007 |
"Created: / 19-07-2019 / 12:02:30 / Claus Gittinger"
|
|
1008 |
"Modified: / 19-07-2019 / 16:44:30 / Claus Gittinger"
|
|
1009 |
"Modified (comment): / 23-07-2019 / 09:32:44 / Claus Gittinger"
|
|
1010 |
!
|
|
1011 |
|
3781
|
1012 |
findComponent:componentNameOrPath in:anApplicationOrViewOrMenuItem
|
3780
|
1013 |
"find a component by name inside an app or inside a view.
|
3727
|
1014 |
Uses the NameKey of the spec, and optionally the label or modelKey.
|
|
1015 |
Can return either a view or a menu item"
|
|
1016 |
|
3793
|
1017 |
|idx app window component componentNameSymbol
|
|
1018 |
foundByName foundByHelpKey foundByTitle foundByLabel item
|
3780
|
1019 |
checkIfAllMenuItemsDoTheSame|
|
|
1020 |
|
|
1021 |
(componentNameOrPath includes:$/) ifTrue:[
|
|
1022 |
(idx := componentNameOrPath indexOf:$/) ~~ 0 ifTrue:[
|
|
1023 |
|containerName restPath container|
|
|
1024 |
|
|
1025 |
containerName := componentNameOrPath copyTo:idx-1.
|
|
1026 |
restPath := componentNameOrPath copyFrom:idx+1.
|
3781
|
1027 |
container := self findComponent:containerName in:anApplicationOrViewOrMenuItem.
|
3780
|
1028 |
container isNil ifTrue:[ ^ nil ].
|
|
1029 |
^ self findComponent:restPath in:container
|
|
1030 |
]
|
|
1031 |
].
|
|
1032 |
|
|
1033 |
componentNameSymbol := componentNameOrPath asSymbolIfInterned ? componentNameOrPath.
|
3727
|
1034 |
|
3781
|
1035 |
(app := anApplicationOrViewOrMenuItem) isView ifTrue:[
|
|
1036 |
window := anApplicationOrViewOrMenuItem.
|
|
1037 |
app := anApplicationOrViewOrMenuItem application
|
3727
|
1038 |
].
|
3781
|
1039 |
app isApplicationModel ifTrue:[
|
3780
|
1040 |
(component := app componentAt:componentNameSymbol) notNil ifTrue:[^ component].
|
|
1041 |
window := window ? app window.
|
3781
|
1042 |
] ifFalse:[
|
|
1043 |
app isMenuItem ifTrue:[
|
|
1044 |
window := app submenu.
|
|
1045 |
]
|
|
1046 |
].
|
3792
|
1047 |
window notNil ifTrue:[
|
|
1048 |
window shown ifFalse:[^ nil].
|
|
1049 |
].
|
|
1050 |
|
3727
|
1051 |
"/ mhmh - search through all widgets of anApplication;
|
|
1052 |
"/ maybe it was not created via the builder/spec,
|
|
1053 |
"/ or it has changed its name.
|
|
1054 |
"/ look for: widget's name, widget's title, widget's label
|
|
1055 |
foundByName := OrderedCollection new.
|
3793
|
1056 |
foundByHelpKey := OrderedCollection new.
|
3727
|
1057 |
foundByTitle := OrderedCollection new.
|
|
1058 |
foundByLabel := OrderedCollection new.
|
3792
|
1059 |
|
3780
|
1060 |
window withAllSubViewsDo:[:each |
|
3727
|
1061 |
|foundIt|
|
|
1062 |
|
|
1063 |
foundIt := false.
|
3780
|
1064 |
each shown ifTrue:[
|
3793
|
1065 |
{
|
|
1066 |
#name . foundByName .
|
|
1067 |
#helpKey . foundByHelpKey .
|
|
1068 |
#title . foundByTitle .
|
|
1069 |
#label . foundByLabel .
|
|
1070 |
} pairWiseDo:[:attr :coll |
|
3727
|
1071 |
foundIt ifFalse:[
|
3780
|
1072 |
[
|
3793
|
1073 |
(each perform:attr) = componentNameSymbol ifTrue:[
|
|
1074 |
coll add:each. foundIt := true
|
|
1075 |
]
|
3780
|
1076 |
] on:MessageNotUnderstood do:[:ex | ].
|
3793
|
1077 |
]
|
|
1078 |
].
|
|
1079 |
foundIt ifFalse:[
|
|
1080 |
each isMenu ifTrue:[
|
|
1081 |
(item := each detectItemForNameKey:componentNameSymbol) notNil ifTrue:[
|
|
1082 |
foundByName add:item. foundIt := true
|
|
1083 |
].
|
3780
|
1084 |
foundIt ifFalse:[
|
3793
|
1085 |
(item := each detectItemForKey:componentNameSymbol) notNil ifTrue:[
|
|
1086 |
foundByName add:item. foundIt := true
|
3780
|
1087 |
].
|
3793
|
1088 |
foundIt ifFalse:[
|
|
1089 |
(item := each detectItemForLabel:componentNameSymbol) notNil ifTrue:[
|
|
1090 |
foundByLabel add:item. foundIt := true
|
|
1091 |
].
|
|
1092 |
].
|
3780
|
1093 |
].
|
3793
|
1094 |
].
|
3780
|
1095 |
].
|
3727
|
1096 |
].
|
|
1097 |
].
|
3780
|
1098 |
|
|
1099 |
"/ a check, if multiple menu items have the same action, then choose the first found
|
|
1100 |
checkIfAllMenuItemsDoTheSame :=
|
|
1101 |
[:itemsFound |
|
|
1102 |
|visibleItems|
|
|
1103 |
|
|
1104 |
(itemsFound conform:[:each | each askFor:#isMenuItem]) ifTrue:[
|
|
1105 |
(itemsFound collect:[:item | item itemValue]) asSet size == 1 ifTrue:[
|
|
1106 |
"/ choose one which is visible, if possible
|
|
1107 |
visibleItems := itemsFound select:[:item | item menuPanel shown].
|
|
1108 |
visibleItems notEmpty ifTrue:[
|
|
1109 |
^ visibleItems first
|
|
1110 |
].
|
|
1111 |
^ itemsFound first.
|
|
1112 |
].
|
|
1113 |
].
|
|
1114 |
].
|
|
1115 |
|
3727
|
1116 |
foundByName notEmpty ifTrue:[
|
3780
|
1117 |
checkIfAllMenuItemsDoTheSame value:foundByName.
|
3727
|
1118 |
self assert:(foundByName size == 1) message:'multiple components found by name'.
|
|
1119 |
^ foundByName first.
|
|
1120 |
].
|
3793
|
1121 |
foundByHelpKey notEmpty ifTrue:[
|
|
1122 |
checkIfAllMenuItemsDoTheSame value:foundByHelpKey.
|
|
1123 |
self assert:(foundByHelpKey size == 1) message:'multiple components found by helpKey'.
|
|
1124 |
^ foundByHelpKey first.
|
|
1125 |
].
|
3727
|
1126 |
foundByTitle notEmpty ifTrue:[
|
3780
|
1127 |
checkIfAllMenuItemsDoTheSame value:foundByTitle.
|
3727
|
1128 |
self assert:(foundByTitle size == 1) message:'multiple components found by title'.
|
|
1129 |
^ foundByTitle first.
|
|
1130 |
].
|
|
1131 |
foundByLabel notEmpty ifTrue:[
|
3780
|
1132 |
checkIfAllMenuItemsDoTheSame value:foundByLabel.
|
3727
|
1133 |
self assert:(foundByLabel size == 1) message:'multiple components found by label'.
|
|
1134 |
^ foundByLabel first.
|
|
1135 |
].
|
|
1136 |
^ component
|
|
1137 |
|
|
1138 |
"
|
|
1139 |
self basicNew findComponent:'Klassen' in:(Transcript topView)
|
|
1140 |
"
|
|
1141 |
|
|
1142 |
"Created: / 19-07-2019 / 11:36:21 / Claus Gittinger"
|
|
1143 |
"Modified (comment): / 23-07-2019 / 09:31:34 / Claus Gittinger"
|
3700
|
1144 |
!
|
|
1145 |
|
3787
|
1146 |
findComponent:componentName inAllApplications:inAllApplicationsBool ifMultiple:exceptionalValue
|
|
1147 |
"find a component by name - in the active and possibly in any app.
|
|
1148 |
Can return either a view or a menu item"
|
|
1149 |
|
|
1150 |
|component candidates modalGroup|
|
|
1151 |
|
|
1152 |
application notNil ifTrue:[
|
|
1153 |
(component := self findComponent:componentName in:application) notNil ifTrue:[
|
|
1154 |
^ component.
|
|
1155 |
].
|
|
1156 |
].
|
|
1157 |
candidates := OrderedCollection new.
|
|
1158 |
|
|
1159 |
"/ is there a modal dialog open for the app?
|
|
1160 |
(modalGroup := application windowGroup modalGroup) notNil ifTrue:[
|
|
1161 |
modalGroup topViews do:[:eachModalTopView |
|
|
1162 |
component := self findComponent:componentName in:eachModalTopView.
|
|
1163 |
component notNil ifTrue:[
|
|
1164 |
candidates add:component
|
|
1165 |
].
|
|
1166 |
].
|
|
1167 |
candidates size == 1 ifTrue:[
|
|
1168 |
^ candidates first
|
|
1169 |
].
|
|
1170 |
].
|
|
1171 |
inAllApplicationsBool ifTrue:[
|
|
1172 |
"/ search through all current applications
|
|
1173 |
WindowGroup scheduledWindowGroups do:[:eachWG |
|
|
1174 |
|eachApp|
|
|
1175 |
|
|
1176 |
(eachApp := eachWG application) notNil ifTrue:[
|
|
1177 |
component := self findComponent:componentName in:eachApp.
|
|
1178 |
component notNil ifTrue:[
|
|
1179 |
candidates add:component
|
|
1180 |
].
|
|
1181 |
].
|
|
1182 |
].
|
3792
|
1183 |
candidates isEmpty ifTrue:[
|
|
1184 |
Display allTopViews do:[:eachTopView |
|
|
1185 |
component := self findComponent:componentName in:eachTopView.
|
|
1186 |
component notNil ifTrue:[
|
|
1187 |
candidates add:component
|
|
1188 |
].
|
|
1189 |
]
|
|
1190 |
].
|
3787
|
1191 |
|
|
1192 |
candidates size == 1 ifTrue:[
|
|
1193 |
^ candidates first
|
|
1194 |
].
|
|
1195 |
candidates notEmpty ifTrue:[
|
|
1196 |
"/ multiple elements (probably there are multiple topviews open...
|
|
1197 |
"/ check the current windowGroup
|
|
1198 |
^ exceptionalValue value
|
|
1199 |
].
|
|
1200 |
].
|
|
1201 |
|
|
1202 |
^ nil
|
|
1203 |
|
|
1204 |
"
|
|
1205 |
ShowMeHowItWorks basicNew findComponent:'Classes'
|
|
1206 |
ShowMeHowItWorks basicNew findComponent:'Klassen'
|
|
1207 |
"
|
|
1208 |
|
|
1209 |
"Created: / 19-07-2019 / 12:02:30 / Claus Gittinger"
|
|
1210 |
"Modified: / 19-07-2019 / 16:44:30 / Claus Gittinger"
|
|
1211 |
"Modified (comment): / 23-07-2019 / 09:32:44 / Claus Gittinger"
|
|
1212 |
!
|
|