3700
|
1 |
"{ Package: 'stx:libtool2' }"
|
|
2 |
|
|
3 |
"{ NameSpace: Smalltalk }"
|
|
4 |
|
|
5 |
Object subclass:#ShowMeHowItWorks
|
3783
|
6 |
instanceVariableNames:'application opStream streamStack lastComponentName lastComponent
|
|
7 |
lastResult voice translate language verifying
|
3784
|
8 |
closeApplicationWhenFinished defaultComponentWaitTime ui'
|
3790
|
9 |
classVariableNames:'IntroShownCount DebugMode StartLabel'
|
3700
|
10 |
poolDictionaries:''
|
|
11 |
category:'Interface-Help'
|
|
12 |
!
|
|
13 |
|
|
14 |
!ShowMeHowItWorks class methodsFor:'documentation'!
|
|
15 |
|
|
16 |
documentation
|
|
17 |
"
|
3713
|
18 |
automatic presentations.
|
|
19 |
To see how it works, open a methodFinder:
|
|
20 |
MethodFinderWindow open
|
|
21 |
and select its 'Show me how it works' item in the help menu.
|
3700
|
22 |
|
|
23 |
[author:]
|
|
24 |
Claus Gittinger
|
|
25 |
"
|
|
26 |
!
|
|
27 |
|
|
28 |
example
|
3713
|
29 |
MethodFinderWindow open.
|
|
30 |
|
3700
|
31 |
ShowMeHowItWorks do:#(
|
|
32 |
( showing: 'Choose the number of arguments' do:(
|
|
33 |
moveTo: NumberOfArguments
|
|
34 |
select: '1'
|
|
35 |
))
|
|
36 |
(showing: 'Click into the "receiver" field' do:(
|
|
37 |
moveTo: ReceiverEditor
|
|
38 |
click: ReceiverEditor
|
|
39 |
))
|
|
40 |
(showing: 'Enter a value (or expression) into "receiver" field' do:(
|
|
41 |
enter: '100'
|
|
42 |
))
|
|
43 |
(showing: 'Click into the "first argument" field' do:(
|
|
44 |
moveTo: Arg1Editor
|
|
45 |
click: ReceiverEditor
|
|
46 |
))
|
|
47 |
(showing: 'Enter a value (or expression) into "receiver" field' do:(
|
|
48 |
enter: '100'
|
|
49 |
))
|
|
50 |
|
|
51 |
)
|
|
52 |
! !
|
|
53 |
|
|
54 |
!ShowMeHowItWorks class methodsFor:'running'!
|
|
55 |
|
3775
|
56 |
application:anApplicationOrNilForAll do:specArray
|
|
57 |
"spec contains a list of action commands (show: / moveTo: etc.)"
|
|
58 |
|
|
59 |
self new
|
|
60 |
application:anApplicationOrNilForAll;
|
|
61 |
do:specArray
|
|
62 |
|
|
63 |
"
|
|
64 |
ShowMeHowItWorks do:
|
|
65 |
#(
|
|
66 |
(language: de)
|
3791
|
67 |
(show: 'üben üben üben')
|
3775
|
68 |
(wait: 0.5)
|
|
69 |
(moveTo: NameOfComponent)
|
|
70 |
)
|
|
71 |
"
|
|
72 |
|
|
73 |
"Created: / 19-07-2019 / 10:52:59 / Claus Gittinger"
|
|
74 |
"Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger"
|
|
75 |
!
|
|
76 |
|
3700
|
77 |
do:specArray
|
3728
|
78 |
"spec contains a list of action commands (show: / moveTo: etc.)"
|
3727
|
79 |
|
3784
|
80 |
self do:specArray withUI:false
|
3700
|
81 |
|
3727
|
82 |
"
|
|
83 |
ShowMeHowItWorks do:
|
|
84 |
#(
|
3728
|
85 |
(language: de)
|
3791
|
86 |
(show: 'üben üben üben')
|
3728
|
87 |
(wait: 0.5)
|
3727
|
88 |
(moveTo: NameOfComponent)
|
|
89 |
)
|
|
90 |
"
|
|
91 |
|
|
92 |
"Created: / 19-07-2019 / 10:52:59 / Claus Gittinger"
|
3728
|
93 |
"Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger"
|
3784
|
94 |
!
|
|
95 |
|
3787
|
96 |
do:specArray from:startLabelOrNil withUI:withUIBoolean
|
|
97 |
"spec contains a list of action commands (show: / moveTo: etc.)"
|
|
98 |
|
|
99 |
self new
|
|
100 |
do:specArray
|
|
101 |
from:startLabelOrNil
|
|
102 |
withUI:withUIBoolean
|
|
103 |
|
|
104 |
"
|
|
105 |
ShowMeHowItWorks
|
|
106 |
do:#(
|
|
107 |
(language: de)
|
3791
|
108 |
(show: 'üben üben üben')
|
3787
|
109 |
(wait: 0.5)
|
|
110 |
(moveTo: NameOfComponent)
|
|
111 |
)
|
|
112 |
withUI:true
|
|
113 |
"
|
|
114 |
|
|
115 |
"Created: / 19-07-2019 / 10:52:59 / Claus Gittinger"
|
|
116 |
"Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger"
|
|
117 |
!
|
|
118 |
|
3784
|
119 |
do:specArray withUI:withUIBoolean
|
|
120 |
"spec contains a list of action commands (show: / moveTo: etc.)"
|
|
121 |
|
|
122 |
self new do:specArray withUI:withUIBoolean
|
|
123 |
|
|
124 |
"
|
|
125 |
ShowMeHowItWorks
|
|
126 |
do:#(
|
|
127 |
(language: de)
|
3791
|
128 |
(show: 'üben üben üben')
|
3784
|
129 |
(wait: 0.5)
|
|
130 |
(moveTo: NameOfComponent)
|
|
131 |
)
|
|
132 |
withUI:true
|
|
133 |
"
|
|
134 |
|
|
135 |
"Created: / 19-07-2019 / 10:52:59 / Claus Gittinger"
|
|
136 |
"Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger"
|
3713
|
137 |
! !
|
|
138 |
|
|
139 |
!ShowMeHowItWorks methodsFor:'accessing'!
|
|
140 |
|
3775
|
141 |
application:anApplication
|
|
142 |
"if set, only that application is presented (widget search is limtied to that one)"
|
|
143 |
|
|
144 |
application := anApplication.
|
3700
|
145 |
! !
|
|
146 |
|
|
147 |
!ShowMeHowItWorks methodsFor:'commands'!
|
|
148 |
|
3711
|
149 |
intro
|
|
150 |
<action>
|
3724
|
151 |
|
3775
|
152 |
verifying ifTrue:[^ self].
|
|
153 |
|
|
154 |
IntroShownCount := (IntroShownCount ? 0).
|
|
155 |
|
3728
|
156 |
"/ only say this a few times..
|
|
157 |
IntroShownCount > 3 ifTrue:[^ self].
|
3775
|
158 |
IntroShownCount := IntroShownCount + 1.
|
|
159 |
|
|
160 |
self language:(Smalltalk language).
|
3724
|
161 |
self tell:(self class classResources
|
3733
|
162 |
string:'You can stop this show, by pressing the SHIFT key').
|
3711
|
163 |
|
|
164 |
"Created: / 19-07-2019 / 15:49:19 / Claus Gittinger"
|
3733
|
165 |
"Modified: / 23-07-2019 / 11:06:13 / Claus Gittinger"
|
3728
|
166 |
!
|
|
167 |
|
3787
|
168 |
label:nameOfLabel
|
|
169 |
<action>
|
|
170 |
|
|
171 |
"/ skipped here; see goto
|
|
172 |
!
|
|
173 |
|
3728
|
174 |
language:lang
|
|
175 |
<action>
|
|
176 |
|
|
177 |
voice := OperatingSystem bestVoiceForLanguage:lang.
|
|
178 |
translate := false.
|
3775
|
179 |
language := lang.
|
3728
|
180 |
|
|
181 |
"Created: / 23-07-2019 / 10:27:02 / Claus Gittinger"
|
3711
|
182 |
!
|
|
183 |
|
3780
|
184 |
open:applicationClassName
|
|
185 |
<action>
|
|
186 |
|
|
187 |
|appClass|
|
|
188 |
|
|
189 |
(appClass := Smalltalk classNamed:applicationClassName) isNil ifTrue:[
|
|
190 |
self error:'no such application class'
|
|
191 |
].
|
|
192 |
verifying ifFalse:[
|
|
193 |
application := appClass new openAndWaitUntilVisible.
|
|
194 |
closeApplicationWhenFinished := true.
|
|
195 |
].
|
|
196 |
|
|
197 |
"Created: / 19-07-2019 / 15:09:45 / Claus Gittinger"
|
|
198 |
!
|
|
199 |
|
3700
|
200 |
pause
|
|
201 |
<action>
|
|
202 |
|
3724
|
203 |
Dialog information:(self class classResources
|
|
204 |
stringWithCRs:'Show Paused.\Click on "OK" to proceed')
|
3700
|
205 |
|
|
206 |
"Created: / 19-07-2019 / 15:03:17 / Claus Gittinger"
|
3711
|
207 |
"Modified: / 19-07-2019 / 16:13:33 / Claus Gittinger"
|
3700
|
208 |
!
|
|
209 |
|
3776
|
210 |
raise:what
|
|
211 |
<action>
|
|
212 |
|
|
213 |
verifying ifTrue:[^ self].
|
|
214 |
|
|
215 |
what == #application ifTrue:[
|
|
216 |
application topView raise.
|
|
217 |
^ self
|
|
218 |
].
|
|
219 |
what == #masterApplication ifTrue:[
|
|
220 |
application windowGroup isModal ifTrue:[
|
|
221 |
application windowGroup mainGroup topViews first raise
|
|
222 |
] ifFalse:[
|
|
223 |
(application masterApplication ? application) topViews first raise.
|
|
224 |
].
|
|
225 |
^ self
|
|
226 |
].
|
|
227 |
self halt.
|
|
228 |
!
|
|
229 |
|
3711
|
230 |
show:message
|
3714
|
231 |
"showing (and speak) some message."
|
3711
|
232 |
|
|
233 |
<action>
|
|
234 |
|
3776
|
235 |
self showing:message saying:nil do:nil
|
3711
|
236 |
|
|
237 |
"Created: / 19-07-2019 / 15:59:18 / Claus Gittinger"
|
3714
|
238 |
"Modified (comment): / 19-07-2019 / 18:54:36 / Claus Gittinger"
|
|
239 |
!
|
|
240 |
|
|
241 |
show:message for:seconds
|
|
242 |
"showing (and speak) some message and wait for some time."
|
|
243 |
|
|
244 |
<action>
|
3780
|
245 |
|
|
246 |
DebugMode == true ifTrue:[^ self].
|
|
247 |
|
3714
|
248 |
self show:message.
|
|
249 |
self wait:seconds.
|
|
250 |
|
|
251 |
"Created: / 19-07-2019 / 18:54:20 / Claus Gittinger"
|
3711
|
252 |
!
|
|
253 |
|
3776
|
254 |
show:message saying:sentenceOrNil
|
|
255 |
"showing (and speak) some message."
|
|
256 |
|
|
257 |
<action>
|
|
258 |
|
|
259 |
self showing:message saying:sentenceOrNil do:nil
|
|
260 |
|
|
261 |
"Created: / 19-07-2019 / 15:59:18 / Claus Gittinger"
|
|
262 |
"Modified (comment): / 19-07-2019 / 18:54:36 / Claus Gittinger"
|
|
263 |
!
|
|
264 |
|
|
265 |
show:message saying:sentenceOrNil for:seconds
|
|
266 |
"showing (and speak) some message and wait for some time."
|
|
267 |
|
|
268 |
<action>
|
|
269 |
|
3780
|
270 |
DebugMode == true ifTrue:[^ self].
|
3776
|
271 |
self show:message saying:sentenceOrNil.
|
|
272 |
self wait:seconds.
|
|
273 |
|
|
274 |
"Created: / 19-07-2019 / 18:54:20 / Claus Gittinger"
|
|
275 |
!
|
|
276 |
|
3711
|
277 |
showing:message do:operationsOrNothing
|
3714
|
278 |
"execute operationsOrNothing while showing (and speaking) some message."
|
3700
|
279 |
|
|
280 |
<action>
|
|
281 |
|
3776
|
282 |
self showing:message saying:nil do:operationsOrNothing
|
|
283 |
!
|
|
284 |
|
|
285 |
showing:message saying:sentenceOrNil do:operationsOrNothing
|
|
286 |
"execute operationsOrNothing while showing (and speaking) some message."
|
|
287 |
|
|
288 |
<action>
|
|
289 |
|
3715
|
290 |
|xLatedMessage messageView talkDone|
|
3700
|
291 |
|
3728
|
292 |
xLatedMessage := (translate and:[application notNil])
|
|
293 |
ifTrue:[application resources string:message]
|
|
294 |
ifFalse:[message].
|
|
295 |
|
3711
|
296 |
self assert:(operationsOrNothing isNil or:[operationsOrNothing isSequenceable]).
|
3700
|
297 |
|
3715
|
298 |
messageView := ActiveHelpView for:xLatedMessage.
|
3700
|
299 |
"/ messageView shapeStyle:#cartoon.
|
|
300 |
[
|
3780
|
301 |
messageView origin:(Screen current pointerPosition + (0 @ 20)).
|
|
302 |
messageView makeFullyVisible.
|
3700
|
303 |
messageView realize.
|
|
304 |
|
|
305 |
self talking ifTrue:[
|
|
306 |
talkDone := Semaphore new.
|
|
307 |
[
|
3776
|
308 |
self tell:(sentenceOrNil ? xLatedMessage).
|
3700
|
309 |
talkDone signal
|
|
310 |
] fork.
|
|
311 |
|
|
312 |
"/
|
|
313 |
"/ allow speaker some headoff
|
3775
|
314 |
verifying ifFalse:[
|
|
315 |
Delay waitForSeconds:(xLatedMessage size / 15)+0.5.
|
|
316 |
].
|
3700
|
317 |
].
|
|
318 |
|
3711
|
319 |
operationsOrNothing notEmptyOrNil ifTrue:[
|
|
320 |
self doStream:(operationsOrNothing readStream).
|
|
321 |
].
|
3700
|
322 |
] ensure:[
|
|
323 |
messageView destroy
|
|
324 |
].
|
|
325 |
self talking ifTrue:[
|
|
326 |
talkDone wait.
|
|
327 |
].
|
|
328 |
|
|
329 |
"Created: / 19-07-2019 / 11:19:27 / Claus Gittinger"
|
3728
|
330 |
"Modified: / 23-07-2019 / 10:52:30 / Claus Gittinger"
|
|
331 |
!
|
|
332 |
|
|
333 |
thankyou
|
|
334 |
<action>
|
|
335 |
|
|
336 |
self show:(self randomThankYou).
|
|
337 |
|
|
338 |
"Created: / 23-07-2019 / 10:50:43 / Claus Gittinger"
|
3700
|
339 |
!
|
|
340 |
|
|
341 |
wait:seconds
|
|
342 |
<action>
|
|
343 |
|
3775
|
344 |
verifying ifTrue:[^ self].
|
3780
|
345 |
DebugMode == true ifTrue:[^ self].
|
3776
|
346 |
Display ctrlDown ifTrue:[^ self].
|
|
347 |
|
3700
|
348 |
Delay waitForSeconds:seconds
|
|
349 |
|
|
350 |
"Created: / 19-07-2019 / 15:09:45 / Claus Gittinger"
|
3780
|
351 |
!
|
|
352 |
|
|
353 |
waitFor:componentName timeout:seconds
|
|
354 |
<action>
|
|
355 |
|
|
356 |
|endTime|
|
|
357 |
|
3781
|
358 |
verifying ifTrue:[^ self].
|
|
359 |
|
3780
|
360 |
endTime := Timestamp now + seconds.
|
3787
|
361 |
[
|
|
362 |
(self findComponent:componentName inAllApplications:true ifMultiple:nil) notNil ifTrue:[
|
3780
|
363 |
^ self
|
|
364 |
].
|
|
365 |
Delay waitForSeconds:0.05.
|
|
366 |
Timestamp now > endTime ifTrue:[
|
|
367 |
self error:('component %1 not present after %2' bindWith:componentName with:seconds)
|
|
368 |
]
|
|
369 |
] loop
|
3700
|
370 |
! !
|
|
371 |
|
3711
|
372 |
!ShowMeHowItWorks methodsFor:'commands - checking'!
|
|
373 |
|
|
374 |
isEmpty:componentName
|
|
375 |
<action>
|
|
376 |
|
|
377 |
|component|
|
|
378 |
|
|
379 |
component := self componentNamed:componentName.
|
|
380 |
component isScrollWrapper ifTrue:[ component := component scrolledView ].
|
|
381 |
component isTextView ifTrue:[
|
|
382 |
^ component contents isEmptyOrNil
|
|
383 |
] ifFalse:[
|
|
384 |
self halt.
|
|
385 |
].
|
|
386 |
self error:'isEmpty: unhandled component type: ',component displayString.
|
|
387 |
|
|
388 |
"Created: / 19-07-2019 / 15:33:47 / Claus Gittinger"
|
|
389 |
!
|
|
390 |
|
|
391 |
unless:query do:actions
|
|
392 |
<action>
|
|
393 |
|
|
394 |
|result|
|
|
395 |
|
|
396 |
result := self doCommand:query.
|
|
397 |
result ifFalse:[
|
|
398 |
self doCommand:actions
|
|
399 |
].
|
|
400 |
|
|
401 |
"Created: / 19-07-2019 / 15:33:32 / Claus Gittinger"
|
|
402 |
! !
|
|
403 |
|
|
404 |
!ShowMeHowItWorks methodsFor:'commands - mouse & keyboard'!
|
|
405 |
|
|
406 |
click
|
|
407 |
"press-release"
|
|
408 |
|
|
409 |
<action>
|
|
410 |
|
|
411 |
^ self click:1 inComponent:lastComponent
|
|
412 |
|
|
413 |
"Created: / 19-07-2019 / 16:11:03 / Claus Gittinger"
|
|
414 |
!
|
3700
|
415 |
|
|
416 |
click:buttonNr
|
|
417 |
"press-release"
|
|
418 |
|
|
419 |
<action>
|
|
420 |
|
3711
|
421 |
self assert:(buttonNr isInteger).
|
|
422 |
^ self click:buttonNr inComponent:lastComponent
|
3700
|
423 |
|
|
424 |
"Created: / 19-07-2019 / 13:21:20 / Claus Gittinger"
|
3711
|
425 |
"Modified: / 19-07-2019 / 16:10:19 / Claus Gittinger"
|
3700
|
426 |
!
|
|
427 |
|
3711
|
428 |
clickIn:componentName
|
|
429 |
"press-release"
|
|
430 |
|
|
431 |
<action>
|
|
432 |
|
|
433 |
^ self click:1 inComponent:(self componentNamed:componentName)
|
|
434 |
|
|
435 |
"Created: / 19-07-2019 / 16:09:58 / Claus Gittinger"
|
|
436 |
!
|
|
437 |
|
3787
|
438 |
drag:itemsIndexOrLabelOrPattern toComponent:targetComponentName dropAt:where
|
|
439 |
"drag an item (by index or label) from the current treeView,
|
|
440 |
into another component.
|
|
441 |
where is one of: #top, #center or #bottom.
|
|
442 |
allowed after moving to:
|
|
443 |
aSelectionInHierarchyView
|
|
444 |
"
|
|
445 |
|
|
446 |
<action>
|
|
447 |
|
3790
|
448 |
self drag:itemsIndexOrLabelOrPattern toComponent:targetComponentName dropAt:where show:nil
|
|
449 |
!
|
|
450 |
|
|
451 |
drag:itemsIndexOrLabelOrPattern toComponent:targetComponentName dropAt:where show:textWhenDroppingOrNil
|
|
452 |
"drag an item (by index or label) from the current treeView,
|
|
453 |
into another component.
|
|
454 |
where is one of: #top, #center or #bottom.
|
|
455 |
allowed after moving to:
|
|
456 |
aSelectionInHierarchyView
|
|
457 |
"
|
|
458 |
|
|
459 |
<action>
|
|
460 |
|
3787
|
461 |
|sourceComponent targetComponent idx yPos sourcePos sourcePosOnScreen
|
3790
|
462 |
targetPos targetPosOnScreen targetPosInSource dNdMgr|
|
3787
|
463 |
|
|
464 |
verifying ifTrue:[^ self].
|
|
465 |
|
|
466 |
targetComponent := self findComponent:targetComponentName.
|
|
467 |
self assert:targetComponent notNil.
|
|
468 |
|
|
469 |
((sourceComponent := lastComponent) isKindOf:ScrollableView) ifTrue:[
|
|
470 |
sourceComponent := sourceComponent scrolledView.
|
|
471 |
].
|
|
472 |
|
3790
|
473 |
where == #topLeft ifTrue:[
|
|
474 |
targetPos := targetComponent topLeft + (1@1).
|
|
475 |
] ifFalse:[
|
|
476 |
where == #topCenter ifTrue:[
|
3791
|
477 |
targetPos := targetComponent topCenter + (0@5).
|
3787
|
478 |
] ifFalse:[
|
|
479 |
where == #center ifTrue:[
|
|
480 |
targetPos := targetComponent center
|
|
481 |
] ifFalse:[
|
3790
|
482 |
where == #bottomCenter ifTrue:[
|
3791
|
483 |
targetPos := targetComponent bottomCenter - (0 @ 5)
|
3790
|
484 |
] ifFalse:[
|
|
485 |
where == #bottomLeft ifTrue:[
|
3791
|
486 |
targetPos := targetComponent bottomLeft + (1 @ -5)
|
3790
|
487 |
] ifFalse:[
|
|
488 |
self error:'where is this'
|
|
489 |
].
|
3787
|
490 |
].
|
|
491 |
].
|
|
492 |
].
|
3790
|
493 |
].
|
|
494 |
|
|
495 |
(sourceComponent isKindOf:HierarchicalListView) ifTrue:[
|
3787
|
496 |
|
|
497 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[
|
|
498 |
idx := itemsIndexOrLabelOrPattern
|
|
499 |
] ifFalse:[
|
|
500 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
|
|
501 |
idx := sourceComponent indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string].
|
|
502 |
] ifFalse:[
|
|
503 |
idx := sourceComponent indexOfElementForWhich:[:el | el label string = itemsIndexOrLabelOrPattern].
|
|
504 |
].
|
|
505 |
idx == 0 ifTrue:[
|
|
506 |
self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern
|
|
507 |
].
|
|
508 |
].
|
|
509 |
yPos := sourceComponent yVisibleOfLine:idx.
|
|
510 |
self movePointerToComponent:sourceComponent rightOffset:(10 @ (yPos + 3)).
|
|
511 |
Delay waitForSeconds:0.5.
|
|
512 |
sourcePosOnScreen := Display pointerPosition.
|
|
513 |
sourcePos := Display translatePoint:sourcePosOnScreen from:nil to:sourceComponent.
|
|
514 |
|
|
515 |
targetPosOnScreen := Display translatePoint:targetPos from:targetComponent to:nil.
|
|
516 |
targetPosInSource := Display translatePoint:targetPosOnScreen from:nil to:sourceComponent.
|
|
517 |
|
|
518 |
sourceComponent simulateButtonPress:1 at:sourcePos sendDisplayEvent:true.
|
3790
|
519 |
dNdMgr := sourceComponent startDragAt:sourcePos.
|
|
520 |
|
|
521 |
textWhenDroppingOrNil notNil ifTrue:[
|
|
522 |
self show:textWhenDroppingOrNil.
|
|
523 |
].
|
|
524 |
|
|
525 |
Delay waitForSeconds:1.
|
3787
|
526 |
self movePointerToComponent:targetComponent offset:targetPos.
|
3790
|
527 |
Delay waitForSeconds:1.
|
|
528 |
dNdMgr buttonMotion:1 x:targetPos x y:targetPos y view:targetComponent.
|
3787
|
529 |
|
3790
|
530 |
sourceComponent simulateButtonRelease:1 at:targetPos sendDisplayEvent:true.
|
|
531 |
dNdMgr buttonRelease:1 x:targetPos x y:targetPos y view:targetComponent.
|
3787
|
532 |
^ self
|
|
533 |
].
|
|
534 |
|
|
535 |
self error:'cannot expand in this component'
|
|
536 |
|
|
537 |
"Created: / 19-07-2019 / 12:34:25 / Claus Gittinger"
|
|
538 |
"Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger"
|
|
539 |
!
|
|
540 |
|
|
541 |
expand:itemsIndexOrLabelOrPattern
|
|
542 |
"expand an item in a treeView by label,
|
|
543 |
allowed after moving to:
|
|
544 |
aSelectionInHierarchyView
|
|
545 |
"
|
|
546 |
|
|
547 |
<action>
|
|
548 |
|
|
549 |
|component|
|
|
550 |
|
|
551 |
verifying ifTrue:[^ self].
|
|
552 |
|
|
553 |
((component := lastComponent) isKindOf:ScrollableView) ifTrue:[
|
|
554 |
component := component scrolledView.
|
|
555 |
].
|
|
556 |
|
|
557 |
(component isKindOf:HierarchicalListView) ifTrue:[
|
|
558 |
|idx yPos|
|
|
559 |
|
|
560 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[
|
|
561 |
idx := itemsIndexOrLabelOrPattern
|
|
562 |
] ifFalse:[
|
|
563 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
|
|
564 |
idx := component indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string].
|
|
565 |
] ifFalse:[
|
|
566 |
idx := component indexOfElementForWhich:[:el | el label string = itemsIndexOrLabelOrPattern].
|
|
567 |
].
|
|
568 |
idx == 0 ifTrue:[
|
|
569 |
self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern
|
|
570 |
].
|
|
571 |
].
|
|
572 |
yPos := component yVisibleOfLine:idx.
|
|
573 |
self movePointerToComponent:component offset:(0 @ (yPos + 3)).
|
|
574 |
Delay waitForSeconds:0.5.
|
|
575 |
(component listAt:idx) expand.
|
|
576 |
^ self
|
|
577 |
].
|
|
578 |
|
|
579 |
self error:'cannot expand in this component'
|
|
580 |
|
|
581 |
"Created: / 19-07-2019 / 12:34:25 / Claus Gittinger"
|
|
582 |
"Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger"
|
|
583 |
!
|
|
584 |
|
3711
|
585 |
fastMoveTo:componentName
|
|
586 |
"move the mouse to componentName without circling"
|
3700
|
587 |
|
|
588 |
<action>
|
|
589 |
|
3711
|
590 |
|component|
|
3700
|
591 |
|
3711
|
592 |
component := self componentNamed:componentName.
|
3717
|
593 |
self movePointerToComponent:component speed:(self pointerMoveSpeedFast).
|
3711
|
594 |
|
3727
|
595 |
"
|
|
596 |
ShowMeHowItWorks basicNew fastMoveTo:'Classes'
|
|
597 |
ShowMeHowItWorks basicNew fastMoveTo:'Klassen'
|
|
598 |
"
|
|
599 |
|
3711
|
600 |
"Created: / 19-07-2019 / 15:39:23 / Claus Gittinger"
|
3717
|
601 |
"Modified: / 20-07-2019 / 08:14:16 / Claus Gittinger"
|
3727
|
602 |
"Modified (comment): / 23-07-2019 / 09:33:31 / Claus Gittinger"
|
3700
|
603 |
!
|
|
604 |
|
|
605 |
moveTo:componentName
|
|
606 |
"move the mouse to componentName,
|
|
607 |
then circle around it a few times"
|
|
608 |
|
|
609 |
<action>
|
|
610 |
|
|
611 |
|component|
|
|
612 |
|
3711
|
613 |
component := self componentNamed:componentName.
|
3700
|
614 |
self movePointerToComponent:component.
|
3776
|
615 |
Display ctrlDown ifTrue:[^ self].
|
3700
|
616 |
self circlePointerAroundComponent:component.
|
|
617 |
|
|
618 |
"Created: / 19-07-2019 / 11:20:42 / Claus Gittinger"
|
3711
|
619 |
"Modified: / 19-07-2019 / 15:38:11 / Claus Gittinger"
|
3700
|
620 |
!
|
|
621 |
|
3787
|
622 |
select:itemsIndexOrLabelOrPattern
|
3700
|
623 |
"select an item by label,
|
|
624 |
allowed after moving to:
|
|
625 |
aComboBox
|
|
626 |
aSelectionInListView
|
|
627 |
"
|
|
628 |
|
|
629 |
<action>
|
|
630 |
|
3783
|
631 |
|idx component|
|
3775
|
632 |
|
|
633 |
verifying ifTrue:[^ self].
|
|
634 |
|
3783
|
635 |
((component := lastComponent) isKindOf:ScrollableView) ifTrue:[
|
|
636 |
component := component scrolledView.
|
|
637 |
].
|
|
638 |
|
|
639 |
(component isKindOf:ComboView) ifTrue:[
|
3700
|
640 |
"/ click on the menubutton
|
3783
|
641 |
self movePointerToComponent:component menuButton.
|
|
642 |
self click:1 inComponent:component menuButton.
|
3700
|
643 |
Delay waitForSeconds:0.3.
|
3787
|
644 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[
|
|
645 |
idx := itemsIndexOrLabelOrPattern
|
|
646 |
] ifFalse:[
|
|
647 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
|
|
648 |
idx := component list findFirst:[:lbl | itemsIndexOrLabelOrPattern match:lbl]
|
|
649 |
] ifFalse:[
|
|
650 |
idx := component list indexOf:itemsIndexOrLabelOrPattern.
|
|
651 |
].
|
|
652 |
idx == 0 ifTrue:[
|
|
653 |
self error:'no such item in comboList: ',itemsIndexOrLabelOrPattern
|
|
654 |
].
|
3700
|
655 |
].
|
3783
|
656 |
component select:idx.
|
3700
|
657 |
Delay waitForSeconds:0.3.
|
3783
|
658 |
component shownMenu notNil ifTrue:[
|
|
659 |
component shownMenu hide.
|
3700
|
660 |
].
|
|
661 |
^ self
|
|
662 |
].
|
3783
|
663 |
(component isKindOf:HierarchicalListView) ifTrue:[
|
3787
|
664 |
|idx yPos|
|
|
665 |
|
|
666 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[
|
|
667 |
idx := itemsIndexOrLabelOrPattern
|
|
668 |
] ifFalse:[
|
|
669 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
|
|
670 |
idx := component indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string].
|
|
671 |
] ifFalse:[
|
|
672 |
idx := component indexOfElementForWhich:[:el | el label string = itemsIndexOrLabelOrPattern].
|
3783
|
673 |
].
|
3787
|
674 |
idx == 0 ifTrue:[
|
|
675 |
self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern
|
|
676 |
].
|
|
677 |
].
|
|
678 |
yPos := component yVisibleOfLine:idx.
|
|
679 |
self movePointerToComponent:component offset:(0 @ (yPos + 3)).
|
|
680 |
component simulateButtonPress:1 at:(0 @ (yPos + 3)) sendDisplayEvent:false.
|
|
681 |
Delay waitForSeconds:0.1.
|
|
682 |
component simulateButtonRelease:1 at:(0 @ (yPos + 3)) sendDisplayEvent:false.
|
|
683 |
"/ component selection:idx.
|
3783
|
684 |
^ self
|
|
685 |
].
|
|
686 |
|
3700
|
687 |
self error:'cannot select this component'
|
|
688 |
|
|
689 |
"Created: / 19-07-2019 / 12:34:25 / Claus Gittinger"
|
|
690 |
"Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger"
|
|
691 |
!
|
|
692 |
|
|
693 |
selectIndex:itemsIndex
|
|
694 |
"select an item by index,
|
|
695 |
allowed after moving to:
|
|
696 |
aComboBox
|
|
697 |
aSelectionInListView
|
|
698 |
"
|
|
699 |
|
|
700 |
<action>
|
|
701 |
|
3716
|
702 |
self selectIndex:itemsIndex in:lastComponent
|
|
703 |
|
|
704 |
"Created: / 19-07-2019 / 14:20:11 / Claus Gittinger"
|
|
705 |
"Modified: / 19-07-2019 / 21:59:36 / Claus Gittinger"
|
|
706 |
!
|
3711
|
707 |
|
3716
|
708 |
selectIndex:itemsIndex in:widgetArg
|
|
709 |
"select an item by index,
|
|
710 |
allowed after moving to:
|
|
711 |
aComboBox
|
|
712 |
aSelectionInListView
|
|
713 |
"
|
|
714 |
|
|
715 |
<action>
|
|
716 |
|
|
717 |
|widget y offset possibleWidgets|
|
|
718 |
|
3775
|
719 |
verifying ifTrue:[^ self].
|
|
720 |
|
3716
|
721 |
(widget := widgetArg) isScrollWrapper ifTrue:[
|
3711
|
722 |
widget := widget scrolledView
|
|
723 |
].
|
|
724 |
|
|
725 |
(widget isKindOf:ComboView) ifTrue:[
|
3700
|
726 |
"/ click on the menubutton
|
3711
|
727 |
self movePointerToComponent:widget menuButton.
|
|
728 |
self click:1 inComponent:widget menuButton.
|
3700
|
729 |
Delay waitForSeconds:0.5.
|
3711
|
730 |
widget select:itemsIndex.
|
3700
|
731 |
Delay waitForSeconds:0.5.
|
|
732 |
^ self
|
|
733 |
].
|
3711
|
734 |
(widget isKindOf:SelectionInListView) ifTrue:[
|
3716
|
735 |
(widget isLineVisible:itemsIndex) ifFalse:[
|
|
736 |
widget scrollToLine:itemsIndex
|
|
737 |
].
|
3711
|
738 |
"/ click on the item
|
|
739 |
y := widget yOfLine:itemsIndex.
|
|
740 |
offset := (widget width // 2) @ y.
|
|
741 |
self movePointerToComponent:widget offset:offset.
|
|
742 |
widget simulateButtonPress:1 at:offset sendDisplayEvent:false.
|
|
743 |
Delay waitForSeconds:(self clickTime).
|
|
744 |
widget simulateButtonRelease:1 at:offset sendDisplayEvent:false.
|
|
745 |
Delay waitForSeconds:0.5.
|
|
746 |
^ self
|
3716
|
747 |
].
|
|
748 |
(widget isKindOf:SelectionInListModelView) ifTrue:[
|
|
749 |
(widget isLineVisible:itemsIndex) ifFalse:[
|
|
750 |
widget scrollToLine:itemsIndex
|
|
751 |
].
|
|
752 |
y := widget yVisibleOfLine:itemsIndex.
|
|
753 |
offset := (widget width // 2) @ y.
|
|
754 |
self movePointerToComponent:widget offset:offset.
|
|
755 |
widget simulateButtonPress:1 at:offset sendDisplayEvent:false.
|
|
756 |
Delay waitForSeconds:(self clickTime).
|
|
757 |
widget simulateButtonRelease:1 at:offset sendDisplayEvent:false.
|
|
758 |
Delay waitForSeconds:0.5.
|
|
759 |
^ self
|
|
760 |
].
|
|
761 |
|
|
762 |
"/ none of it - see what is in there
|
|
763 |
possibleWidgets := OrderedCollection new.
|
|
764 |
widget allSubViewsDo:[:each |
|
|
765 |
((each isKindOf:ComboView)
|
|
766 |
or:[(each isKindOf:SelectionInListView)
|
|
767 |
or:[(each isKindOf:SelectionInListModelView)
|
|
768 |
]]) ifTrue:[
|
|
769 |
possibleWidgets add:each
|
|
770 |
]
|
|
771 |
].
|
|
772 |
possibleWidgets size == 1 ifTrue:[
|
|
773 |
self selectIndex:itemsIndex in:(possibleWidgets first).
|
|
774 |
^ self
|
3711
|
775 |
].
|
3716
|
776 |
|
3700
|
777 |
self error:'cannot select this component'
|
|
778 |
|
3716
|
779 |
"Created: / 19-07-2019 / 21:59:15 / Claus Gittinger"
|
|
780 |
"Modified: / 20-07-2019 / 07:57:41 / Claus Gittinger"
|
3711
|
781 |
!
|
|
782 |
|
|
783 |
type:aString
|
|
784 |
"enter text into the last component"
|
|
785 |
|
|
786 |
<action>
|
|
787 |
|
3776
|
788 |
|t|
|
|
789 |
|
3775
|
790 |
verifying ifTrue:[^ self].
|
|
791 |
|
3776
|
792 |
t := Display ctrlDown ifTrue:[0.05] ifFalse:[0.1].
|
|
793 |
lastComponent
|
|
794 |
simulateTextInput:aString at:(lastComponent extent // 2)
|
|
795 |
sendDisplayEvent:false keyPressTime:t
|
3711
|
796 |
|
|
797 |
"Created: / 19-07-2019 / 15:50:40 / Claus Gittinger"
|
3700
|
798 |
! !
|
|
799 |
|
|
800 |
!ShowMeHowItWorks methodsFor:'defaults'!
|
|
801 |
|
|
802 |
circlingCount
|
|
803 |
"circle around move-end position that many times"
|
|
804 |
|
|
805 |
^ 3
|
|
806 |
|
|
807 |
"Created: / 19-07-2019 / 13:03:45 / Claus Gittinger"
|
|
808 |
!
|
|
809 |
|
|
810 |
circlingRadius
|
|
811 |
"radius when circling"
|
|
812 |
|
|
813 |
^ 30 "/ pixels
|
|
814 |
|
|
815 |
"Created: / 19-07-2019 / 13:07:59 / Claus Gittinger"
|
|
816 |
!
|
|
817 |
|
|
818 |
circlingSpeed
|
|
819 |
"time per round when circling"
|
|
820 |
|
|
821 |
^ 0.3 seconds. "/ time per round
|
|
822 |
|
|
823 |
"Created: / 19-07-2019 / 13:02:34 / Claus Gittinger"
|
|
824 |
!
|
|
825 |
|
|
826 |
clickTime
|
|
827 |
"when clicking"
|
|
828 |
|
3711
|
829 |
^ self shortClickTime
|
3700
|
830 |
|
|
831 |
"Created: / 19-07-2019 / 13:17:20 / Claus Gittinger"
|
3711
|
832 |
"Modified: / 19-07-2019 / 15:21:51 / Claus Gittinger"
|
|
833 |
!
|
|
834 |
|
|
835 |
longClickTime
|
|
836 |
"when clicking buttons"
|
|
837 |
|
|
838 |
^ 500 milliseconds
|
|
839 |
|
|
840 |
"Created: / 19-07-2019 / 15:21:42 / Claus Gittinger"
|
3700
|
841 |
!
|
|
842 |
|
|
843 |
pointerAnimationDelay
|
|
844 |
^ 50 milliseconds. "/ 20 updates per second
|
|
845 |
|
|
846 |
"Created: / 19-07-2019 / 13:04:45 / Claus Gittinger"
|
|
847 |
!
|
|
848 |
|
|
849 |
pointerMoveSpeed
|
|
850 |
^ 400. "/ pixels per second
|
|
851 |
|
|
852 |
"Created: / 19-07-2019 / 13:05:40 / Claus Gittinger"
|
|
853 |
!
|
|
854 |
|
3717
|
855 |
pointerMoveSpeedFast
|
|
856 |
^ 600. "/ pixels per second
|
|
857 |
|
|
858 |
"Created: / 20-07-2019 / 08:13:58 / Claus Gittinger"
|
|
859 |
!
|
|
860 |
|
3711
|
861 |
shortClickTime
|
|
862 |
"when clicking"
|
|
863 |
|
|
864 |
^ 100 milliseconds
|
|
865 |
|
|
866 |
"Created: / 19-07-2019 / 15:21:29 / Claus Gittinger"
|
|
867 |
!
|
|
868 |
|
3700
|
869 |
talking
|
3780
|
870 |
"/ DebugMode := true
|
3775
|
871 |
verifying ifTrue:[^ false].
|
3780
|
872 |
DebugMode == true ifTrue:[^ false].
|
3775
|
873 |
|
3727
|
874 |
"/ ^ Expecco::ExpeccoPreferences current speechEffectsEnabled
|
3700
|
875 |
^ true
|
|
876 |
|
|
877 |
"Created: / 19-07-2019 / 14:31:14 / Claus Gittinger"
|
3727
|
878 |
"Modified (comment): / 23-07-2019 / 09:45:35 / Claus Gittinger"
|
3700
|
879 |
! !
|
|
880 |
|
|
881 |
!ShowMeHowItWorks methodsFor:'helper'!
|
|
882 |
|
3715
|
883 |
randomThankYou
|
|
884 |
^ #(
|
|
885 |
'thank you, for watching'
|
|
886 |
'thank you for watching'
|
|
887 |
'thank you'
|
3775
|
888 |
'thanks'
|
3715
|
889 |
'have a good day'
|
3775
|
890 |
'have a nice day'
|
3715
|
891 |
'have fun'
|
|
892 |
'have fun with expecco'
|
|
893 |
'have fun with expecco, by the way: expecco comes from the latin word: peccare, which means: "to sin"'
|
|
894 |
'happy hacking'
|
|
895 |
'happy hacking, I hope you liked what you saw'
|
|
896 |
'hope you liked it'
|
|
897 |
'see you again'
|
3775
|
898 |
'be the source with you'
|
|
899 |
'be the force with you'
|
|
900 |
'may the force be with you'
|
|
901 |
'may the source be with you'
|
3715
|
902 |
'please give feedback, and let us know, if you liked it'
|
|
903 |
'if you have any questions, please contact exept'
|
|
904 |
'if you need more information, please take a look at the wiki'
|
|
905 |
) atRandom
|
|
906 |
|
|
907 |
"
|
3775
|
908 |
OperatingSystem speak:'may the source be with you'
|
3715
|
909 |
OperatingSystem speak:'have fun with expecco'
|
3716
|
910 |
OperatingSystem speak:'have fun with expecco, by the way: expecco comes from the latin word: peccare, which means: to sin'
|
3715
|
911 |
OperatingSystem speak:'happy hacking, I hope you liked what you saw'
|
|
912 |
OperatingSystem speak:'please give feedback, and let us know, if you liked it'
|
|
913 |
OperatingSystem speak:'if you have any questions, please contact exept'
|
|
914 |
OperatingSystem speak:'if you need more information, please take a look at the wiki'
|
|
915 |
"
|
|
916 |
|
|
917 |
"Created: / 19-07-2019 / 21:39:18 / Claus Gittinger"
|
|
918 |
!
|
|
919 |
|
3700
|
920 |
tell:message
|
|
921 |
self talking ifTrue:[
|
3728
|
922 |
OperatingSystem speak:message voiceName:voice.
|
3700
|
923 |
].
|
|
924 |
|
|
925 |
"Created: / 19-07-2019 / 14:57:50 / Claus Gittinger"
|
3728
|
926 |
"Modified: / 23-07-2019 / 10:28:02 / Claus Gittinger"
|
3700
|
927 |
! !
|
|
928 |
|
|
929 |
!ShowMeHowItWorks methodsFor:'helpers - broken'!
|
|
930 |
|
|
931 |
click:buttonNr atPosition:position
|
|
932 |
"press-release at position"
|
|
933 |
|
|
934 |
|screen|
|
|
935 |
|
3775
|
936 |
verifying ifTrue:[^ self].
|
|
937 |
|
3700
|
938 |
screen := Screen current.
|
|
939 |
|
|
940 |
screen setPointerPosition:position.
|
|
941 |
screen flush.
|
|
942 |
self click:buttonNr
|
|
943 |
|
|
944 |
"Created: / 19-07-2019 / 13:14:51 / Claus Gittinger"
|
|
945 |
! !
|
|
946 |
|
3727
|
947 |
!ShowMeHowItWorks methodsFor:'helpers - component search'!
|
|
948 |
|
|
949 |
componentNamed:componentName
|
|
950 |
"retrieve a component by name or report an error if not found.
|
|
951 |
Can return either a view or a menu item"
|
|
952 |
|
|
953 |
|component|
|
|
954 |
|
|
955 |
lastComponentName := componentName.
|
|
956 |
|
|
957 |
component := self findComponent:componentName.
|
|
958 |
component isNil ifTrue:[
|
3784
|
959 |
self error:'no component found for: ',componentName mayProceed:verifying.
|
|
960 |
^ nil
|
3727
|
961 |
].
|
|
962 |
lastComponent := component.
|
|
963 |
^ component
|
|
964 |
|
|
965 |
"Created: / 19-07-2019 / 15:37:35 / Claus Gittinger"
|
|
966 |
"Modified (comment): / 23-07-2019 / 09:31:53 / Claus Gittinger"
|
|
967 |
!
|
|
968 |
|
|
969 |
findComponent:componentName
|
|
970 |
"find a component by name - in the active and possibly in any app.
|
|
971 |
Can return either a view or a menu item"
|
|
972 |
|
3787
|
973 |
^ self
|
|
974 |
findComponent:componentName
|
|
975 |
inAllApplications:true
|
|
976 |
ifMultiple:[
|
|
977 |
self proceedableError:('multiple components found by name: ',componentName).
|
|
978 |
nil
|
3727
|
979 |
].
|
3780
|
980 |
|
3787
|
981 |
"
|
|
982 |
ShowMeHowItWorks basicNew findComponent:'Classes'
|
|
983 |
ShowMeHowItWorks basicNew findComponent:'Klassen'
|
|
984 |
"
|
3780
|
985 |
|
3787
|
986 |
"Created: / 19-07-2019 / 12:02:30 / Claus Gittinger"
|
|
987 |
"Modified: / 19-07-2019 / 16:44:30 / Claus Gittinger"
|
|
988 |
"Modified (comment): / 23-07-2019 / 09:32:44 / Claus Gittinger"
|
|
989 |
!
|
|
990 |
|
|
991 |
findComponent:componentName ifMultiple:exceptionalValue
|
|
992 |
"find a component by name - in the active and possibly in any app.
|
|
993 |
Can return either a view or a menu item"
|
|
994 |
|
|
995 |
^ self
|
|
996 |
findComponent:componentName
|
|
997 |
inAllApplications:true
|
|
998 |
ifMultiple:exceptionalValue
|
3727
|
999 |
|
|
1000 |
"
|
|
1001 |
ShowMeHowItWorks basicNew findComponent:'Classes'
|
|
1002 |
ShowMeHowItWorks basicNew findComponent:'Klassen'
|
|
1003 |
"
|
|
1004 |
|
|
1005 |
"Created: / 19-07-2019 / 12:02:30 / Claus Gittinger"
|
|
1006 |
"Modified: / 19-07-2019 / 16:44:30 / Claus Gittinger"
|
|
1007 |
"Modified (comment): / 23-07-2019 / 09:32:44 / Claus Gittinger"
|
|
1008 |
!
|
|
1009 |
|
3781
|
1010 |
findComponent:componentNameOrPath in:anApplicationOrViewOrMenuItem
|
3780
|
1011 |
"find a component by name inside an app or inside a view.
|
3727
|
1012 |
Uses the NameKey of the spec, and optionally the label or modelKey.
|
|
1013 |
Can return either a view or a menu item"
|
|
1014 |
|
3780
|
1015 |
|idx app window component componentNameSymbol foundByName foundByTitle foundByLabel item
|
|
1016 |
checkIfAllMenuItemsDoTheSame|
|
|
1017 |
|
|
1018 |
(componentNameOrPath includes:$/) ifTrue:[
|
|
1019 |
(idx := componentNameOrPath indexOf:$/) ~~ 0 ifTrue:[
|
|
1020 |
|containerName restPath container|
|
|
1021 |
|
|
1022 |
containerName := componentNameOrPath copyTo:idx-1.
|
|
1023 |
restPath := componentNameOrPath copyFrom:idx+1.
|
3781
|
1024 |
container := self findComponent:containerName in:anApplicationOrViewOrMenuItem.
|
3780
|
1025 |
container isNil ifTrue:[ ^ nil ].
|
|
1026 |
^ self findComponent:restPath in:container
|
|
1027 |
]
|
|
1028 |
].
|
|
1029 |
|
|
1030 |
componentNameSymbol := componentNameOrPath asSymbolIfInterned ? componentNameOrPath.
|
3727
|
1031 |
|
3781
|
1032 |
(app := anApplicationOrViewOrMenuItem) isView ifTrue:[
|
|
1033 |
window := anApplicationOrViewOrMenuItem.
|
|
1034 |
app := anApplicationOrViewOrMenuItem application
|
3727
|
1035 |
].
|
3781
|
1036 |
app isApplicationModel ifTrue:[
|
3780
|
1037 |
(component := app componentAt:componentNameSymbol) notNil ifTrue:[^ component].
|
|
1038 |
window := window ? app window.
|
3781
|
1039 |
] ifFalse:[
|
|
1040 |
app isMenuItem ifTrue:[
|
|
1041 |
window := app submenu.
|
|
1042 |
]
|
|
1043 |
].
|
3727
|
1044 |
|
|
1045 |
"/ mhmh - search through all widgets of anApplication;
|
|
1046 |
"/ maybe it was not created via the builder/spec,
|
|
1047 |
"/ or it has changed its name.
|
|
1048 |
"/ look for: widget's name, widget's title, widget's label
|
|
1049 |
foundByName := OrderedCollection new.
|
|
1050 |
foundByTitle := OrderedCollection new.
|
|
1051 |
foundByLabel := OrderedCollection new.
|
|
1052 |
|
3780
|
1053 |
window withAllSubViewsDo:[:each |
|
3727
|
1054 |
|foundIt|
|
|
1055 |
|
|
1056 |
foundIt := false.
|
3780
|
1057 |
each shown ifTrue:[
|
3727
|
1058 |
[
|
3780
|
1059 |
each name = componentNameSymbol ifTrue:[ foundByName add:each. foundIt := true ].
|
3727
|
1060 |
] on:MessageNotUnderstood do:[:ex | ].
|
|
1061 |
foundIt ifFalse:[
|
|
1062 |
[
|
3780
|
1063 |
each title = componentNameSymbol ifTrue:[ foundByTitle add:each. foundIt := true ].
|
3727
|
1064 |
] on:MessageNotUnderstood do:[:ex | ].
|
|
1065 |
foundIt ifFalse:[
|
3780
|
1066 |
[
|
|
1067 |
each label = componentNameSymbol ifTrue:[ foundByLabel add:each. foundIt := true ].
|
|
1068 |
] on:MessageNotUnderstood do:[:ex | ].
|
|
1069 |
foundIt ifFalse:[
|
|
1070 |
each isMenu ifTrue:[
|
|
1071 |
(item := each detectItemForNameKey:componentNameSymbol) notNil ifTrue:[
|
|
1072 |
foundByName add:item. foundIt := true
|
|
1073 |
].
|
3727
|
1074 |
foundIt ifFalse:[
|
3780
|
1075 |
(item := each detectItemForKey:componentNameSymbol) notNil ifTrue:[
|
|
1076 |
foundByName add:item. foundIt := true
|
3727
|
1077 |
].
|
3780
|
1078 |
foundIt ifFalse:[
|
|
1079 |
(item := each detectItemForLabel:componentNameSymbol) notNil ifTrue:[
|
|
1080 |
foundByLabel add:item. foundIt := true
|
|
1081 |
].
|
|
1082 |
].
|
3727
|
1083 |
].
|
3780
|
1084 |
].
|
|
1085 |
].
|
|
1086 |
]
|
|
1087 |
].
|
3727
|
1088 |
].
|
|
1089 |
].
|
3780
|
1090 |
|
|
1091 |
"/ a check, if multiple menu items have the same action, then choose the first found
|
|
1092 |
checkIfAllMenuItemsDoTheSame :=
|
|
1093 |
[:itemsFound |
|
|
1094 |
|visibleItems|
|
|
1095 |
|
|
1096 |
(itemsFound conform:[:each | each askFor:#isMenuItem]) ifTrue:[
|
|
1097 |
(itemsFound collect:[:item | item itemValue]) asSet size == 1 ifTrue:[
|
|
1098 |
"/ choose one which is visible, if possible
|
|
1099 |
visibleItems := itemsFound select:[:item | item menuPanel shown].
|
|
1100 |
visibleItems notEmpty ifTrue:[
|
|
1101 |
^ visibleItems first
|
|
1102 |
].
|
|
1103 |
^ itemsFound first.
|
|
1104 |
].
|
|
1105 |
].
|
|
1106 |
].
|
|
1107 |
|
3727
|
1108 |
foundByName notEmpty ifTrue:[
|
3780
|
1109 |
checkIfAllMenuItemsDoTheSame value:foundByName.
|
3727
|
1110 |
self assert:(foundByName size == 1) message:'multiple components found by name'.
|
|
1111 |
^ foundByName first.
|
|
1112 |
].
|
|
1113 |
foundByTitle notEmpty ifTrue:[
|
3780
|
1114 |
checkIfAllMenuItemsDoTheSame value:foundByTitle.
|
3727
|
1115 |
self assert:(foundByTitle size == 1) message:'multiple components found by title'.
|
|
1116 |
^ foundByTitle first.
|
|
1117 |
].
|
|
1118 |
foundByLabel notEmpty ifTrue:[
|
3780
|
1119 |
checkIfAllMenuItemsDoTheSame value:foundByLabel.
|
3727
|
1120 |
self assert:(foundByLabel size == 1) message:'multiple components found by label'.
|
|
1121 |
^ foundByLabel first.
|
|
1122 |
].
|
|
1123 |
^ component
|
|
1124 |
|
|
1125 |
"
|
|
1126 |
self basicNew findComponent:'Klassen' in:(Transcript topView)
|
|
1127 |
"
|
|
1128 |
|
|
1129 |
"Created: / 19-07-2019 / 11:36:21 / Claus Gittinger"
|
|
1130 |
"Modified (comment): / 23-07-2019 / 09:31:34 / Claus Gittinger"
|
3700
|
1131 |
!
|
|
1132 |
|
3787
|
1133 |
findComponent:componentName inAllApplications:inAllApplicationsBool ifMultiple:exceptionalValue
|
|
1134 |
"find a component by name - in the active and possibly in any app.
|
|
1135 |
Can return either a view or a menu item"
|
|
1136 |
|
|
1137 |
|component candidates modalGroup|
|
|
1138 |
|
|
1139 |
application notNil ifTrue:[
|
|
1140 |
(component := self findComponent:componentName in:application) notNil ifTrue:[
|
|
1141 |
^ component.
|
|
1142 |
].
|
|
1143 |
].
|
|
1144 |
candidates := OrderedCollection new.
|
|
1145 |
|
|
1146 |
"/ is there a modal dialog open for the app?
|
|
1147 |
(modalGroup := application windowGroup modalGroup) notNil ifTrue:[
|
|
1148 |
modalGroup topViews do:[:eachModalTopView |
|
|
1149 |
component := self findComponent:componentName in:eachModalTopView.
|
|
1150 |
component notNil ifTrue:[
|
|
1151 |
candidates add:component
|
|
1152 |
].
|
|
1153 |
].
|
|
1154 |
candidates size == 1 ifTrue:[
|
|
1155 |
^ candidates first
|
|
1156 |
].
|
|
1157 |
].
|
|
1158 |
inAllApplicationsBool ifTrue:[
|
|
1159 |
"/ search through all current applications
|
|
1160 |
WindowGroup scheduledWindowGroups do:[:eachWG |
|
|
1161 |
|eachApp|
|
|
1162 |
|
|
1163 |
(eachApp := eachWG application) notNil ifTrue:[
|
|
1164 |
component := self findComponent:componentName in:eachApp.
|
|
1165 |
component notNil ifTrue:[
|
|
1166 |
candidates add:component
|
|
1167 |
].
|
|
1168 |
].
|
|
1169 |
].
|
|
1170 |
|
|
1171 |
candidates size == 1 ifTrue:[
|
|
1172 |
^ candidates first
|
|
1173 |
].
|
|
1174 |
candidates notEmpty ifTrue:[
|
|
1175 |
"/ multiple elements (probably there are multiple topviews open...
|
|
1176 |
"/ check the current windowGroup
|
|
1177 |
^ exceptionalValue value
|
|
1178 |
].
|
|
1179 |
].
|
|
1180 |
|
|
1181 |
^ nil
|
|
1182 |
|
|
1183 |
"
|
|
1184 |
ShowMeHowItWorks basicNew findComponent:'Classes'
|
|
1185 |
ShowMeHowItWorks basicNew findComponent:'Klassen'
|
|
1186 |
"
|
|
1187 |
|
|
1188 |
"Created: / 19-07-2019 / 12:02:30 / Claus Gittinger"
|
|
1189 |
"Modified: / 19-07-2019 / 16:44:30 / Claus Gittinger"
|
|
1190 |
"Modified (comment): / 23-07-2019 / 09:32:44 / Claus Gittinger"
|
|
1191 |
!
|
|
1192 |
|
3780
|
1193 |
screenBoundsOfComponent:aWidgetOrMenuItem
|
3727
|
1194 |
aWidgetOrMenuItem isView ifTrue:[
|
3780
|
1195 |
^ aWidgetOrMenuItem screenBounds
|
|
1196 |
].
|
|
1197 |
(aWidgetOrMenuItem askFor:#isMenuItem) ifTrue:[
|
|
1198 |
|menuPanel menuBounds|
|
3717
|
1199 |
|
3780
|
1200 |
aWidgetOrMenuItem isVisible ifTrue:[
|
|
1201 |
aWidgetOrMenuItem layout notNil ifTrue:[
|
|
1202 |
menuPanel := aWidgetOrMenuItem menuPanel.
|
|
1203 |
menuPanel shown ifTrue:[
|
|
1204 |
menuBounds := menuPanel screenBounds.
|
|
1205 |
^ aWidgetOrMenuItem layout + menuBounds origin
|
|
1206 |
].
|
|
1207 |
].
|
|
1208 |
].
|
3700
|
1209 |
].
|
3780
|
1210 |
^ nil.
|
3711
|
1211 |
! !
|
|
1212 |
|
3780
|
1213 |
!ShowMeHowItWorks methodsFor:'helpers - mouse buttons'!
|
3711
|
1214 |
|
|
1215 |
click:buttonNr inComponent:component
|
|
1216 |
"press-release in a component"
|
|
1217 |
|
|
1218 |
|t|
|
|
1219 |
|
|
1220 |
t := self shortClickTime.
|
|
1221 |
(component isKindOf:Button) ifTrue:[
|
|
1222 |
t := self longClickTime
|
|
1223 |
].
|
|
1224 |
self click:buttonNr inComponent:component clickTime:t
|
|
1225 |
|
|
1226 |
"Created: / 19-07-2019 / 13:18:27 / Claus Gittinger"
|
|
1227 |
"Modified: / 19-07-2019 / 15:22:47 / Claus Gittinger"
|
|
1228 |
!
|
|
1229 |
|
3780
|
1230 |
click:buttonNr inComponent:viewOrMenuItem clickTime:clickTime
|
3711
|
1231 |
"press-release in a component"
|
|
1232 |
|
3780
|
1233 |
|viewToClick clickPos|
|
|
1234 |
|
|
1235 |
self assert:viewOrMenuItem notNil.
|
3775
|
1236 |
verifying ifTrue:[^ self].
|
|
1237 |
|
3780
|
1238 |
(viewOrMenuItem askFor:#isMenuItem) ifTrue:[
|
|
1239 |
viewToClick := viewOrMenuItem menuPanel.
|
|
1240 |
clickPos := viewOrMenuItem layout center.
|
|
1241 |
self assert:(clickPos notNil).
|
|
1242 |
] ifFalse:[
|
|
1243 |
viewToClick := viewOrMenuItem.
|
|
1244 |
clickPos := viewToClick extent // 2.
|
|
1245 |
].
|
|
1246 |
|
|
1247 |
viewToClick simulateButtonPress:buttonNr at:clickPos sendDisplayEvent:false.
|
3711
|
1248 |
Delay waitForSeconds:clickTime.
|
3780
|
1249 |
viewToClick simulateButtonRelease:buttonNr at:clickPos sendDisplayEvent:false.
|
3711
|
1250 |
|
|
1251 |
"/ self click:buttonNr atPosition:(component extent // 2)
|
|
1252 |
|
|
1253 |
"Created: / 19-07-2019 / 15:21:05 / Claus Gittinger"
|
3700
|
1254 |
!
|
|
1255 |
|
|
1256 |
press:buttonNr
|
|
1257 |
"press at the current position"
|
|
1258 |
|
|
1259 |
|position screen x y|
|
|
1260 |
|
3775
|
1261 |
verifying ifTrue:[^ self].
|
|
1262 |
|
3700
|
1263 |
screen := Screen current.
|
|
1264 |
position := screen pointerPosition.
|
|
1265 |
x := position x.
|
|
1266 |
y := position y.
|
|
1267 |
|
3787
|
1268 |
"/ self movePointerToScreenPosition:position.
|
3700
|
1269 |
|
|
1270 |
false "OperatingSystem isOSXlike" ifTrue:[
|
|
1271 |
|osxPos|
|
|
1272 |
|
|
1273 |
osxPos := OperatingSystem getMousePosition.
|
|
1274 |
x := osxPos x rounded.
|
|
1275 |
y := osxPos y rounded.
|
|
1276 |
OperatingSystem generateButtonEvent:buttonNr down:true x:x y:y.
|
|
1277 |
^ self.
|
|
1278 |
].
|
|
1279 |
|
|
1280 |
screen sendKeyOrButtonEvent:#buttonPress x:x y:y keyOrButton:buttonNr state:0 toViewId:(screen rootWindowId).
|
|
1281 |
screen flush.
|
|
1282 |
|
|
1283 |
"Created: / 19-07-2019 / 13:52:38 / Claus Gittinger"
|
3727
|
1284 |
"Modified: / 23-07-2019 / 09:38:31 / Claus Gittinger"
|
3700
|
1285 |
!
|
|
1286 |
|
|
1287 |
release:buttonNr
|
|
1288 |
"press-release at the current position"
|
|
1289 |
|
|
1290 |
|position screen x y|
|
|
1291 |
|
3775
|
1292 |
verifying ifTrue:[^ self].
|
|
1293 |
|
3700
|
1294 |
screen := Screen current.
|
|
1295 |
position := screen pointerPosition.
|
|
1296 |
x := position x.
|
|
1297 |
y := position y.
|
|
1298 |
|
3787
|
1299 |
"/ self movePointerToScreenPosition:position.
|
3700
|
1300 |
|
|
1301 |
false "OperatingSystem isOSXlike" ifTrue:[
|
|
1302 |
|osxPos|
|
|
1303 |
|
|
1304 |
osxPos := OperatingSystem getMousePosition.
|
|
1305 |
x := osxPos x rounded.
|
|
1306 |
y := osxPos y rounded.
|
|
1307 |
OperatingSystem generateButtonEvent:buttonNr down:false x:x y:y.
|
|
1308 |
^ self.
|
|
1309 |
].
|
|
1310 |
|
|
1311 |
screen sendKeyOrButtonEvent:#buttonRelease x:x y:y keyOrButton:buttonNr state:0 toViewId:(screen rootWindowId).
|
|
1312 |
screen flush.
|
|
1313 |
|
|
1314 |
"Created: / 19-07-2019 / 13:53:05 / Claus Gittinger"
|
3727
|
1315 |
"Modified: / 23-07-2019 / 09:38:38 / Claus Gittinger"
|
3700
|
1316 |
! !
|
|
1317 |
|
3780
|
1318 |
!ShowMeHowItWorks methodsFor:'helpers - mouse movement'!
|
|
1319 |
|
|
1320 |
circlePointerAroundComponent:aWidgetOrMenuItem
|
|
1321 |
"circle around it a few times"
|
|
1322 |
|
|
1323 |
|bounds position|
|
|
1324 |
|
|
1325 |
bounds := self screenBoundsOfComponent:aWidgetOrMenuItem.
|
|
1326 |
bounds isNil ifTrue:[
|
|
1327 |
self error:'no bounds found for: ',aWidgetOrMenuItem printString.
|
|
1328 |
].
|
|
1329 |
position := bounds center rounded.
|
|
1330 |
self circlePointerAroundScreenPosition:position
|
|
1331 |
|
|
1332 |
"Created: / 19-07-2019 / 13:12:35 / Claus Gittinger"
|
|
1333 |
"Modified: / 23-07-2019 / 09:38:12 / Claus Gittinger"
|
|
1334 |
!
|
|
1335 |
|
|
1336 |
circlePointerAroundScreenPosition:position
|
|
1337 |
"circle around it a few times"
|
|
1338 |
|
|
1339 |
|screen stepDelayTime numCircles circlingSpeed radius|
|
|
1340 |
|
|
1341 |
verifying ifTrue:[^ self].
|
|
1342 |
|
|
1343 |
screen := Screen current.
|
|
1344 |
|
|
1345 |
circlingSpeed := self circlingSpeed. "/ time per round
|
|
1346 |
numCircles := self circlingCount.
|
|
1347 |
stepDelayTime := self pointerAnimationDelay. "/ update interval
|
|
1348 |
|
|
1349 |
radius := self circlingRadius.
|
|
1350 |
|
|
1351 |
"/ move it around a few times
|
|
1352 |
1 to:numCircles do:[:round |
|
|
1353 |
|n angle|
|
|
1354 |
|
|
1355 |
n := circlingSpeed / stepDelayTime. "/ nr of steps per circle
|
|
1356 |
angle := 360 / n. "/ angle-delta per step
|
|
1357 |
1 to:n do:[:step |
|
|
1358 |
|a x y|
|
|
1359 |
|
|
1360 |
a := angle * step.
|
|
1361 |
"/ clockwise starting above the center
|
|
1362 |
x := position x + (radius * a degreesToRadians sin).
|
|
1363 |
y := position y + (radius * a degreesToRadians cos).
|
|
1364 |
"/ Transcript showCR:(x@y).
|
|
1365 |
screen setPointerPosition:(x@y) rounded.
|
|
1366 |
screen flush.
|
|
1367 |
Delay waitFor:stepDelayTime.
|
|
1368 |
].
|
|
1369 |
"/ and back
|
|
1370 |
screen setPointerPosition:position rounded.
|
|
1371 |
screen flush.
|
|
1372 |
Delay waitFor:stepDelayTime.
|
|
1373 |
].
|
|
1374 |
|
|
1375 |
"Created: / 23-07-2019 / 09:37:46 / Claus Gittinger"
|
|
1376 |
!
|
|
1377 |
|
|
1378 |
fastMovePointerToScreenPosition:position
|
|
1379 |
self movePointerToScreenPosition:position speed:(self pointerMoveSpeedFast).
|
|
1380 |
|
|
1381 |
"Created: / 23-07-2019 / 09:36:20 / Claus Gittinger"
|
|
1382 |
!
|
|
1383 |
|
|
1384 |
movePointerToComponent:aWidgetOrMenuItem
|
|
1385 |
"move the mouse to aWidget's center"
|
|
1386 |
|
|
1387 |
|bounds|
|
|
1388 |
|
|
1389 |
bounds := self screenBoundsOfComponent:aWidgetOrMenuItem.
|
|
1390 |
self movePointerToScreenPosition:(bounds center rounded).
|
|
1391 |
|
|
1392 |
"Created: / 19-07-2019 / 13:11:33 / Claus Gittinger"
|
|
1393 |
"Modified: / 23-07-2019 / 09:37:01 / Claus Gittinger"
|
|
1394 |
!
|
|
1395 |
|
|
1396 |
movePointerToComponent:aWidgetOrMenuItem offset:offset
|
|
1397 |
"move the mouse to position inside aWidget's"
|
|
1398 |
|
|
1399 |
|bounds|
|
|
1400 |
|
|
1401 |
bounds := self screenBoundsOfComponent:aWidgetOrMenuItem.
|
|
1402 |
self movePointerToScreenPosition:(bounds origin + offset) rounded.
|
|
1403 |
|
|
1404 |
"Created: / 19-07-2019 / 16:18:58 / Claus Gittinger"
|
|
1405 |
"Modified: / 23-07-2019 / 09:36:57 / Claus Gittinger"
|
|
1406 |
!
|
|
1407 |
|
3787
|
1408 |
movePointerToComponent:aWidgetOrMenuItem rightBottomOffset:offset
|
|
1409 |
"move the mouse to position inside aWidget's.
|
|
1410 |
Offset is from the rightBottom"
|
|
1411 |
|
|
1412 |
|bounds|
|
|
1413 |
|
|
1414 |
bounds := self screenBoundsOfComponent:aWidgetOrMenuItem.
|
|
1415 |
self movePointerToScreenPosition:(bounds corner - offset) rounded.
|
|
1416 |
|
|
1417 |
"Created: / 19-07-2019 / 16:18:58 / Claus Gittinger"
|
|
1418 |
"Modified: / 23-07-2019 / 09:36:57 / Claus Gittinger"
|
|
1419 |
!
|
|
1420 |
|
|
1421 |
movePointerToComponent:aWidgetOrMenuItem rightOffset:offset
|
|
1422 |
"move the mouse to position inside aWidget's.
|
|
1423 |
Offset is from the rightTop (i.e. x is subtracted, y is added)"
|
|
1424 |
|
|
1425 |
|bounds pos|
|
|
1426 |
|
|
1427 |
bounds := self screenBoundsOfComponent:aWidgetOrMenuItem.
|
|
1428 |
pos := (bounds right - offset x) @ (bounds top + offset y).
|
|
1429 |
self movePointerToScreenPosition:pos rounded.
|
|
1430 |
|
|
1431 |
"Created: / 19-07-2019 / 16:18:58 / Claus Gittinger"
|
|
1432 |
"Modified: / 23-07-2019 / 09:36:57 / Claus Gittinger"
|
|
1433 |
!
|
|
1434 |
|
3780
|
1435 |
movePointerToComponent:aWidgetOrMenuItem speed:pixelsPerSecond
|
|
1436 |
"move the mouse to aWidget's center"
|
|
1437 |
|
|
1438 |
|bounds position|
|
|
1439 |
|
|
1440 |
bounds := self screenBoundsOfComponent:aWidgetOrMenuItem.
|
|
1441 |
bounds isNil ifTrue:[
|
|
1442 |
self error:'no bounds found for: ',aWidgetOrMenuItem printString.
|
|
1443 |
].
|
|
1444 |
position := bounds center rounded.
|
|
1445 |
self movePointerToScreenPosition:position speed:pixelsPerSecond.
|
|
1446 |
|
|
1447 |
"Created: / 20-07-2019 / 08:12:49 / Claus Gittinger"
|
|
1448 |
"Modified: / 23-07-2019 / 09:37:27 / Claus Gittinger"
|
|
1449 |
!
|
|
1450 |
|
|
1451 |
movePointerToScreenPosition:newPosition
|
|
1452 |
"move the mouse to newPosition"
|
|
1453 |
|
|
1454 |
self movePointerToScreenPosition:newPosition speed:(self pointerMoveSpeed)
|
|
1455 |
|
|
1456 |
"Created: / 23-07-2019 / 09:36:39 / Claus Gittinger"
|
|
1457 |
!
|
|
1458 |
|
|
1459 |
movePointerToScreenPosition:newPosition speed:pixelsPerSecond
|
|
1460 |
"move the mouse to newPosition, which is a screen position"
|
|
1461 |
|
|
1462 |
|screen distance start numSteps moveTime stepDelayTime delta|
|
|
1463 |
|
|
1464 |
verifying ifTrue:[^ self].
|
|
1465 |
|
|
1466 |
screen := Screen current.
|
|
1467 |
start := screen pointerPosition.
|
|
1468 |
|
|
1469 |
distance := start dist:newPosition.
|
|
1470 |
moveTime := (distance / pixelsPerSecond) seconds. "/ time to move
|
|
1471 |
stepDelayTime := self pointerAnimationDelay. "/ update every 50ms
|
|
1472 |
|
|
1473 |
numSteps := moveTime / stepDelayTime.
|
|
1474 |
numSteps = 0 ifTrue:[
|
|
1475 |
"/ already there
|
|
1476 |
^ self
|
|
1477 |
].
|
|
1478 |
|
|
1479 |
delta := (newPosition - start) / numSteps.
|
|
1480 |
1 to:numSteps do:[:step |
|
|
1481 |
|p|
|
|
1482 |
|
|
1483 |
p := (start + (delta * step)) rounded.
|
|
1484 |
"/ Transcript showCR:p.
|
|
1485 |
screen setPointerPosition:p.
|
|
1486 |
screen flush.
|
|
1487 |
Delay waitFor:stepDelayTime.
|
|
1488 |
].
|
|
1489 |
|
|
1490 |
"Created: / 23-07-2019 / 09:36:45 / Claus Gittinger"
|
|
1491 |
! !
|
|
1492 |
|
3700
|
1493 |
!ShowMeHowItWorks methodsFor:'running'!
|
|
1494 |
|
3728
|
1495 |
do:specArray
|
|
1496 |
"must run as a separate process;
|
|
1497 |
otherwise - if started by the app itself -
|
|
1498 |
no events will be processed while running"
|
3784
|
1499 |
|
3790
|
1500 |
"/ StartLabel := nil.
|
|
1501 |
"/ StartLabel := 'start'.
|
|
1502 |
self do:specArray from:StartLabel
|
3787
|
1503 |
|
3784
|
1504 |
|
|
1505 |
"
|
|
1506 |
ShowMeHowItWorks do:
|
|
1507 |
#(
|
|
1508 |
(show: 'blah blah')
|
|
1509 |
(moveTo: NameOfComponent)
|
|
1510 |
)
|
|
1511 |
"
|
|
1512 |
|
|
1513 |
"Created: / 23-07-2019 / 10:24:53 / Claus Gittinger"
|
|
1514 |
"Modified: / 25-07-2019 / 11:48:53 / Claus Gittinger"
|
|
1515 |
!
|
|
1516 |
|
3787
|
1517 |
do:specArray from:startLabelOrNil withUI:withUIBoolean
|
|
1518 |
"must run as a separate process;
|
|
1519 |
otherwise - if started by the app itself -
|
|
1520 |
no events will be processed while running"
|
|
1521 |
|
|
1522 |
withUIBoolean ifTrue:[
|
|
1523 |
ui := ShowMeHowItWorksRunner openOn:self.
|
|
1524 |
].
|
|
1525 |
self do:specArray from:startLabelOrNil
|
|
1526 |
|
|
1527 |
"
|
|
1528 |
ShowMeHowItWorks
|
|
1529 |
do:#(
|
|
1530 |
(show: 'blah blah')
|
|
1531 |
(moveTo: NameOfComponent)
|
|
1532 |
)
|
|
1533 |
withUI:true
|
|
1534 |
"
|
|
1535 |
|
|
1536 |
"Created: / 23-07-2019 / 10:24:53 / Claus Gittinger"
|
|
1537 |
"Modified: / 25-07-2019 / 11:48:53 / Claus Gittinger"
|
|
1538 |
!
|
|
1539 |
|
3784
|
1540 |
do:specArray withUI:withUIBoolean
|
|
1541 |
"must run as a separate process;
|
|
1542 |
otherwise - if started by the app itself -
|
|
1543 |
no events will be processed while running"
|
|
1544 |
|
|
1545 |
withUIBoolean ifTrue:[
|
|
1546 |
ui := ShowMeHowItWorksRunner openOn:self.
|
|
1547 |
].
|
3787
|
1548 |
self do:specArray from:nil
|
3784
|
1549 |
|
|
1550 |
"
|
|
1551 |
ShowMeHowItWorks
|
|
1552 |
do:#(
|
|
1553 |
(show: 'blah blah')
|
|
1554 |
(moveTo: NameOfComponent)
|
|
1555 |
)
|
|
1556 |
withUI:true
|
|
1557 |
"
|
|
1558 |
|
|
1559 |
"Created: / 23-07-2019 / 10:24:53 / Claus Gittinger"
|
|
1560 |
"Modified: / 25-07-2019 / 11:48:53 / Claus Gittinger"
|
|
1561 |
!
|
|
1562 |
|
|
1563 |
prepare
|
3775
|
1564 |
language isNil ifTrue:[
|
|
1565 |
self language:(Smalltalk language).
|
|
1566 |
].
|
3728
|
1567 |
translate := false.
|
|
1568 |
|
|
1569 |
application isNil ifTrue:[
|
|
1570 |
application := WindowGroup activeMainApplication.
|
|
1571 |
].
|
3780
|
1572 |
closeApplicationWhenFinished := false.
|
3783
|
1573 |
defaultComponentWaitTime isNil ifTrue:[ defaultComponentWaitTime := 1 ].
|
3775
|
1574 |
|
3784
|
1575 |
"Created: / 23-07-2019 / 10:24:53 / Claus Gittinger"
|
|
1576 |
"Modified: / 25-07-2019 / 11:48:53 / Claus Gittinger"
|
|
1577 |
!
|
|
1578 |
|
|
1579 |
verify:specArray
|
3775
|
1580 |
"/ run in verifying mode
|
|
1581 |
verifying := true.
|
3728
|
1582 |
[
|
|
1583 |
Error handle:[:ex |
|
3784
|
1584 |
Transcript showCR:('Possible error (encountered while verifying):\.... %1' withCRs)
|
|
1585 |
with:ex description withCRs.
|
3776
|
1586 |
Display ctrlDown ifTrue:[ex reject].
|
3728
|
1587 |
] do:[
|
3784
|
1588 |
self show:' '. "/ to avoid an audible disturbance on OSX
|
3728
|
1589 |
self doStream:(specArray readStream)
|
|
1590 |
].
|
3775
|
1591 |
] ensure:[
|
|
1592 |
verifying := false.
|
|
1593 |
].
|
|
1594 |
! !
|
|
1595 |
|
|
1596 |
!ShowMeHowItWorks methodsFor:'running - private'!
|
3728
|
1597 |
|
3787
|
1598 |
do:specArray from:startLabelOrNil
|
|
1599 |
"must run as a separate process;
|
|
1600 |
otherwise - if started by the app itself -
|
|
1601 |
no events will be processed while running"
|
|
1602 |
|
3790
|
1603 |
|wasFlyByActive|
|
3787
|
1604 |
|
3790
|
1605 |
(wasFlyByActive := FlyByHelp isSuspended) ifFalse:[
|
|
1606 |
FlyByHelp suspend.
|
3787
|
1607 |
].
|
3790
|
1608 |
|
3787
|
1609 |
self prepare.
|
|
1610 |
|
|
1611 |
"/ run once in verifying mode
|
|
1612 |
[
|
|
1613 |
self verify:specArray.
|
|
1614 |
] ensure:[
|
3790
|
1615 |
wasFlyByActive ifTrue:[FlyByHelp resume].
|
3787
|
1616 |
].
|
|
1617 |
|
|
1618 |
[
|
3790
|
1619 |
FlyByHelp suspend.
|
|
1620 |
|
3787
|
1621 |
[
|
|
1622 |
Error handle:[:ex |
|
|
1623 |
Dialog warn:(self class classResources
|
|
1624 |
stringWithCRs:'An error was encountered in the show:\\%1'
|
|
1625 |
with:ex description withCRs)
|
|
1626 |
] do:[
|
|
1627 |
self doStream:(specArray readStream) from:startLabelOrNil
|
|
1628 |
].
|
|
1629 |
] ensure:[
|
3790
|
1630 |
wasFlyByActive ifTrue:[FlyByHelp resume].
|
3787
|
1631 |
].
|
|
1632 |
] fork.
|
|
1633 |
|
|
1634 |
"
|
|
1635 |
ShowMeHowItWorks do:
|
|
1636 |
#(
|
|
1637 |
(show: 'blah blah')
|
|
1638 |
(moveTo: NameOfComponent)
|
|
1639 |
)
|
|
1640 |
"
|
|
1641 |
|
|
1642 |
"Created: / 23-07-2019 / 10:24:53 / Claus Gittinger"
|
|
1643 |
"Modified: / 25-07-2019 / 11:48:53 / Claus Gittinger"
|
|
1644 |
!
|
|
1645 |
|
3711
|
1646 |
doCommand:op
|
3727
|
1647 |
"execute a single command"
|
|
1648 |
|
3711
|
1649 |
|numArgs sel args method|
|
|
1650 |
|
|
1651 |
op isArray ifTrue:[
|
|
1652 |
op first isArray ifTrue:[
|
|
1653 |
self doStream:op readStream.
|
|
1654 |
^ self.
|
|
1655 |
].
|
|
1656 |
|
|
1657 |
"/ construct a selector from keyword parts at odd indices
|
|
1658 |
sel := ((op with:(1 to:op size) select:[:el :idx | idx odd]) asStringWith:'') asSymbol.
|
|
1659 |
"/ construct arg vector from parts at even indices
|
|
1660 |
args := op with:(1 to:op size) select:[:el :idx | idx even].
|
|
1661 |
] ifFalse:[
|
|
1662 |
sel := op.
|
|
1663 |
numArgs := sel argumentCount.
|
|
1664 |
args := opStream next:numArgs.
|
|
1665 |
].
|
|
1666 |
|
|
1667 |
(self respondsTo:sel) ifFalse:[
|
|
1668 |
self error:'bad operation: ',sel
|
|
1669 |
].
|
|
1670 |
method := self class lookupMethodFor:sel.
|
|
1671 |
(method hasAnnotation:#action) ifFalse:[self halt].
|
|
1672 |
|
|
1673 |
lastResult := self perform:sel withArguments:args.
|
|
1674 |
^ lastResult
|
|
1675 |
|
|
1676 |
"<<END
|
|
1677 |
ShowMeHowItWorks do:#(
|
|
1678 |
showing: 'Choose the number of arguments'
|
|
1679 |
do: (
|
|
1680 |
moveTo: NumberOfArguments
|
|
1681 |
select: '1'
|
|
1682 |
)
|
|
1683 |
showing: 'Click into the "receiver" field'
|
|
1684 |
do: (
|
|
1685 |
moveTo: ReceiverEditor
|
|
1686 |
click: ReceiverEditor
|
|
1687 |
)
|
|
1688 |
showing: 'Enter a value (or expression) into "receiver" field'
|
|
1689 |
do: (
|
|
1690 |
enter: '100'
|
|
1691 |
)
|
|
1692 |
showing: 'Click into the "first argument" field'
|
|
1693 |
do: (
|
|
1694 |
moveTo: Arg1Editor
|
|
1695 |
click: ReceiverEditor
|
|
1696 |
)
|
|
1697 |
showing: 'Enter a value (or expression) into "receiver" field'
|
|
1698 |
do: (
|
|
1699 |
enter: '100'
|
|
1700 |
)
|
|
1701 |
)
|
|
1702 |
END"
|
|
1703 |
|
|
1704 |
"Created: / 19-07-2019 / 15:34:55 / Claus Gittinger"
|
3727
|
1705 |
"Modified: / 23-07-2019 / 09:14:26 / Claus Gittinger"
|
3711
|
1706 |
!
|
|
1707 |
|
3700
|
1708 |
doStream:specStream
|
3787
|
1709 |
self doStream:specStream from:nil
|
|
1710 |
|
|
1711 |
"<<END
|
|
1712 |
ShowMeHowItWorks do:#(
|
|
1713 |
showing: 'Choose the number of arguments'
|
|
1714 |
do: (
|
|
1715 |
moveTo: NumberOfArguments
|
|
1716 |
select: '1'
|
|
1717 |
)
|
|
1718 |
showing: 'Click into the "receiver" field'
|
|
1719 |
do: (
|
|
1720 |
moveTo: ReceiverEditor
|
|
1721 |
click: ReceiverEditor
|
|
1722 |
)
|
|
1723 |
showing: 'Enter a value (or expression) into "receiver" field'
|
|
1724 |
do: (
|
|
1725 |
enter: '100'
|
|
1726 |
)
|
|
1727 |
showing: 'Click into the "first argument" field'
|
|
1728 |
do: (
|
|
1729 |
moveTo: Arg1Editor
|
|
1730 |
click: ReceiverEditor
|
|
1731 |
)
|
|
1732 |
showing: 'Enter a value (or expression) into "receiver" field'
|
|
1733 |
do: (
|
|
1734 |
enter: '100'
|
|
1735 |
)
|
|
1736 |
)
|
|
1737 |
END"
|
|
1738 |
|
|
1739 |
"Created: / 19-07-2019 / 10:52:24 / Claus Gittinger"
|
|
1740 |
"Modified: / 23-07-2019 / 11:48:45 / Claus Gittinger"
|
|
1741 |
!
|
|
1742 |
|
|
1743 |
doStream:specStream from:startLabelOrNil
|
3715
|
1744 |
|previousStream resources|
|
3700
|
1745 |
|
3715
|
1746 |
resources := self class classResources.
|
3783
|
1747 |
|
|
1748 |
streamStack isNil ifTrue:[ streamStack := OrderedCollection new ].
|
|
1749 |
streamStack add:opStream.
|
|
1750 |
|
3700
|
1751 |
previousStream := opStream.
|
|
1752 |
[
|
3787
|
1753 |
|nextCommand|
|
|
1754 |
|
3700
|
1755 |
opStream := specStream.
|
3787
|
1756 |
startLabelOrNil notNil ifTrue:[
|
|
1757 |
|found|
|
|
1758 |
|
|
1759 |
"/ skip for that label
|
|
1760 |
found := false.
|
|
1761 |
[ found ] whileFalse:[
|
|
1762 |
|cmd|
|
|
1763 |
|
|
1764 |
cmd := opStream nextOrNil.
|
|
1765 |
cmd isNil ifTrue:[
|
|
1766 |
self proceedableError:'label not found: ',startLabelOrNil.
|
|
1767 |
^ self.
|
|
1768 |
].
|
|
1769 |
(cmd = 'label:') ifTrue:[
|
|
1770 |
found := (opStream next = startLabelOrNil)
|
|
1771 |
].
|
|
1772 |
].
|
|
1773 |
].
|
|
1774 |
|
3700
|
1775 |
[opStream atEnd] whileFalse:[
|
3787
|
1776 |
nextCommand := opStream next.
|
|
1777 |
self doCommand:nextCommand.
|
|
1778 |
|
3700
|
1779 |
Display shiftDown ifTrue:[
|
3728
|
1780 |
(IntroShownCount ? 0) > 3 ifFalse:[
|
3738
|
1781 |
self tell:(self possiblyTranslate:'You pressed the SHIFT key.').
|
3728
|
1782 |
].
|
3738
|
1783 |
self tell:(self possiblyTranslate:'Do you want to stop the show?').
|
3715
|
1784 |
(Dialog confirm:(resources stringWithCRs:'Stop the demonstration?'))
|
3714
|
1785 |
ifTrue:[
|
3738
|
1786 |
self tell:(self possiblyTranslate:'OK,').
|
|
1787 |
self tell:(self possiblyTranslate:(self randomThankYou)).
|
3714
|
1788 |
^ AbortOperationRequest raise
|
|
1789 |
].
|
3700
|
1790 |
].
|
|
1791 |
].
|
|
1792 |
] ensure:[
|
3783
|
1793 |
streamStack removeLast.
|
3700
|
1794 |
opStream := previousStream
|
|
1795 |
].
|
|
1796 |
|
|
1797 |
"<<END
|
|
1798 |
ShowMeHowItWorks do:#(
|
|
1799 |
showing: 'Choose the number of arguments'
|
|
1800 |
do: (
|
|
1801 |
moveTo: NumberOfArguments
|
|
1802 |
select: '1'
|
|
1803 |
)
|
|
1804 |
showing: 'Click into the "receiver" field'
|
|
1805 |
do: (
|
|
1806 |
moveTo: ReceiverEditor
|
|
1807 |
click: ReceiverEditor
|
|
1808 |
)
|
|
1809 |
showing: 'Enter a value (or expression) into "receiver" field'
|
|
1810 |
do: (
|
|
1811 |
enter: '100'
|
|
1812 |
)
|
|
1813 |
showing: 'Click into the "first argument" field'
|
|
1814 |
do: (
|
|
1815 |
moveTo: Arg1Editor
|
|
1816 |
click: ReceiverEditor
|
|
1817 |
)
|
|
1818 |
showing: 'Enter a value (or expression) into "receiver" field'
|
|
1819 |
do: (
|
|
1820 |
enter: '100'
|
|
1821 |
)
|
|
1822 |
)
|
|
1823 |
END"
|
|
1824 |
|
|
1825 |
"Created: / 19-07-2019 / 10:52:24 / Claus Gittinger"
|
3738
|
1826 |
"Modified: / 23-07-2019 / 11:48:45 / Claus Gittinger"
|
3700
|
1827 |
!
|
|
1828 |
|
3738
|
1829 |
possiblyTranslate:aString
|
|
1830 |
translate ifTrue:[^ self class classResources string:aString].
|
|
1831 |
^ aString
|
|
1832 |
|
|
1833 |
"Created: / 23-07-2019 / 11:48:17 / Claus Gittinger"
|
3700
|
1834 |
! !
|
|
1835 |
|
|
1836 |
!ShowMeHowItWorks class methodsFor:'documentation'!
|
|
1837 |
|
|
1838 |
version_CVS
|
|
1839 |
^ '$Header$'
|
|
1840 |
! !
|
|
1841 |
|