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