3711
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
3700
|
3 |
"{ Package: 'stx:libtool2' }"
|
|
4 |
|
|
5 |
"{ NameSpace: Smalltalk }"
|
|
6 |
|
|
7 |
Object subclass:#ShowMeHowItWorks
|
3713
|
8 |
instanceVariableNames:'application opStream lastComponentName lastComponent lastResult'
|
3700
|
9 |
classVariableNames:''
|
|
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 |
|
|
56 |
do:specArray
|
|
57 |
self doStream:specArray readStream
|
|
58 |
|
|
59 |
"Created: / 19-07-2019 / 10:52:59 / Claus Gittinger"
|
|
60 |
"Modified: / 19-07-2019 / 14:30:43 / Claus Gittinger"
|
|
61 |
!
|
|
62 |
|
|
63 |
doStream:specStream
|
|
64 |
"must run as a separate process;
|
|
65 |
otherwise - if started by the app itself -
|
|
66 |
no events will be processed while running"
|
3713
|
67 |
|
|
68 |
|appWhichStartedMe|
|
|
69 |
|
|
70 |
appWhichStartedMe := WindowGroup activeMainApplication.
|
|
71 |
|
3700
|
72 |
[
|
3713
|
73 |
self new
|
|
74 |
application:appWhichStartedMe;
|
|
75 |
doStream:specStream
|
3700
|
76 |
] fork.
|
|
77 |
|
|
78 |
"Created: / 19-07-2019 / 10:53:07 / Claus Gittinger"
|
3713
|
79 |
"Modified: / 19-07-2019 / 16:44:02 / Claus Gittinger"
|
|
80 |
! !
|
|
81 |
|
|
82 |
!ShowMeHowItWorks methodsFor:'accessing'!
|
|
83 |
|
|
84 |
application:something
|
|
85 |
application := something.
|
3700
|
86 |
! !
|
|
87 |
|
|
88 |
!ShowMeHowItWorks methodsFor:'commands'!
|
|
89 |
|
3711
|
90 |
intro
|
|
91 |
<action>
|
3724
|
92 |
|
|
93 |
self tell:(self class classResources
|
|
94 |
string:'you can stop the show - by pressing - the shift key').
|
3711
|
95 |
|
|
96 |
"Created: / 19-07-2019 / 15:49:19 / Claus Gittinger"
|
|
97 |
!
|
|
98 |
|
3700
|
99 |
pause
|
|
100 |
<action>
|
|
101 |
|
3724
|
102 |
Dialog information:(self class classResources
|
|
103 |
stringWithCRs:'Show Paused.\Click on "OK" to proceed')
|
3700
|
104 |
|
|
105 |
"Created: / 19-07-2019 / 15:03:17 / Claus Gittinger"
|
3711
|
106 |
"Modified: / 19-07-2019 / 16:13:33 / Claus Gittinger"
|
3700
|
107 |
!
|
|
108 |
|
3711
|
109 |
show:message
|
3714
|
110 |
"showing (and speak) some message."
|
3711
|
111 |
|
|
112 |
<action>
|
|
113 |
|
|
114 |
self showing:message do:nil
|
|
115 |
|
|
116 |
"Created: / 19-07-2019 / 15:59:18 / Claus Gittinger"
|
3714
|
117 |
"Modified (comment): / 19-07-2019 / 18:54:36 / Claus Gittinger"
|
|
118 |
!
|
|
119 |
|
|
120 |
show:message for:seconds
|
|
121 |
"showing (and speak) some message and wait for some time."
|
|
122 |
|
|
123 |
<action>
|
|
124 |
|
|
125 |
self show:message.
|
|
126 |
self wait:seconds.
|
|
127 |
|
|
128 |
"Created: / 19-07-2019 / 18:54:20 / Claus Gittinger"
|
3711
|
129 |
!
|
|
130 |
|
|
131 |
showing:message do:operationsOrNothing
|
3714
|
132 |
"execute operationsOrNothing while showing (and speaking) some message."
|
3700
|
133 |
|
|
134 |
<action>
|
|
135 |
|
3715
|
136 |
|xLatedMessage messageView talkDone|
|
3700
|
137 |
|
3715
|
138 |
xLatedMessage := application notNil
|
|
139 |
ifTrue:[application resources string:message]
|
|
140 |
ifFalse:[message].
|
|
141 |
|
3711
|
142 |
self assert:(operationsOrNothing isNil or:[operationsOrNothing isSequenceable]).
|
3700
|
143 |
|
3715
|
144 |
messageView := ActiveHelpView for:xLatedMessage.
|
3700
|
145 |
"/ messageView shapeStyle:#cartoon.
|
|
146 |
[
|
3715
|
147 |
messageView origin:(Screen current pointerPosition).
|
3700
|
148 |
messageView realize.
|
|
149 |
|
|
150 |
self talking ifTrue:[
|
|
151 |
talkDone := Semaphore new.
|
|
152 |
[
|
3715
|
153 |
self tell:xLatedMessage.
|
3700
|
154 |
talkDone signal
|
|
155 |
] fork.
|
|
156 |
|
|
157 |
"/
|
|
158 |
"/ allow speaker some headoff
|
3715
|
159 |
Delay waitForSeconds:(xLatedMessage size / 30).
|
3700
|
160 |
].
|
|
161 |
|
3711
|
162 |
operationsOrNothing notEmptyOrNil ifTrue:[
|
|
163 |
self doStream:(operationsOrNothing readStream).
|
|
164 |
].
|
3700
|
165 |
] ensure:[
|
|
166 |
messageView destroy
|
|
167 |
].
|
|
168 |
self talking ifTrue:[
|
|
169 |
talkDone wait.
|
|
170 |
].
|
|
171 |
|
|
172 |
"Created: / 19-07-2019 / 11:19:27 / Claus Gittinger"
|
3715
|
173 |
"Modified: / 19-07-2019 / 21:37:07 / Claus Gittinger"
|
3700
|
174 |
!
|
|
175 |
|
|
176 |
wait:seconds
|
|
177 |
<action>
|
|
178 |
|
|
179 |
Delay waitForSeconds:seconds
|
|
180 |
|
|
181 |
"Created: / 19-07-2019 / 15:09:45 / Claus Gittinger"
|
|
182 |
! !
|
|
183 |
|
3711
|
184 |
!ShowMeHowItWorks methodsFor:'commands - checking'!
|
|
185 |
|
|
186 |
isEmpty:componentName
|
|
187 |
<action>
|
|
188 |
|
|
189 |
|component|
|
|
190 |
|
|
191 |
component := self componentNamed:componentName.
|
|
192 |
component isScrollWrapper ifTrue:[ component := component scrolledView ].
|
|
193 |
component isTextView ifTrue:[
|
|
194 |
^ component contents isEmptyOrNil
|
|
195 |
] ifFalse:[
|
|
196 |
self halt.
|
|
197 |
].
|
|
198 |
self error:'isEmpty: unhandled component type: ',component displayString.
|
|
199 |
|
|
200 |
"Created: / 19-07-2019 / 15:33:47 / Claus Gittinger"
|
|
201 |
!
|
|
202 |
|
|
203 |
unless:query do:actions
|
|
204 |
<action>
|
|
205 |
|
|
206 |
|result|
|
|
207 |
|
|
208 |
result := self doCommand:query.
|
|
209 |
result ifFalse:[
|
|
210 |
self doCommand:actions
|
|
211 |
].
|
|
212 |
|
|
213 |
"Created: / 19-07-2019 / 15:33:32 / Claus Gittinger"
|
|
214 |
! !
|
|
215 |
|
|
216 |
!ShowMeHowItWorks methodsFor:'commands - mouse & keyboard'!
|
|
217 |
|
|
218 |
click
|
|
219 |
"press-release"
|
|
220 |
|
|
221 |
<action>
|
|
222 |
|
|
223 |
^ self click:1 inComponent:lastComponent
|
|
224 |
|
|
225 |
"Created: / 19-07-2019 / 16:11:03 / Claus Gittinger"
|
|
226 |
!
|
3700
|
227 |
|
|
228 |
click:buttonNr
|
|
229 |
"press-release"
|
|
230 |
|
|
231 |
<action>
|
|
232 |
|
3711
|
233 |
self assert:(buttonNr isInteger).
|
|
234 |
^ self click:buttonNr inComponent:lastComponent
|
3700
|
235 |
|
|
236 |
"Created: / 19-07-2019 / 13:21:20 / Claus Gittinger"
|
3711
|
237 |
"Modified: / 19-07-2019 / 16:10:19 / Claus Gittinger"
|
3700
|
238 |
!
|
|
239 |
|
3711
|
240 |
clickIn:componentName
|
|
241 |
"press-release"
|
|
242 |
|
|
243 |
<action>
|
|
244 |
|
|
245 |
^ self click:1 inComponent:(self componentNamed:componentName)
|
|
246 |
|
|
247 |
"Created: / 19-07-2019 / 16:09:58 / Claus Gittinger"
|
|
248 |
!
|
|
249 |
|
|
250 |
fastMoveTo:componentName
|
|
251 |
"move the mouse to componentName without circling"
|
3700
|
252 |
|
|
253 |
<action>
|
|
254 |
|
3711
|
255 |
|component|
|
3700
|
256 |
|
3711
|
257 |
component := self componentNamed:componentName.
|
3717
|
258 |
self movePointerToComponent:component speed:(self pointerMoveSpeedFast).
|
3711
|
259 |
|
|
260 |
"Created: / 19-07-2019 / 15:39:23 / Claus Gittinger"
|
3717
|
261 |
"Modified: / 20-07-2019 / 08:14:16 / Claus Gittinger"
|
3700
|
262 |
!
|
|
263 |
|
|
264 |
moveTo:componentName
|
|
265 |
"move the mouse to componentName,
|
|
266 |
then circle around it a few times"
|
|
267 |
|
|
268 |
<action>
|
|
269 |
|
|
270 |
|component|
|
|
271 |
|
3711
|
272 |
component := self componentNamed:componentName.
|
3700
|
273 |
self movePointerToComponent:component.
|
|
274 |
self circlePointerAroundComponent:component.
|
|
275 |
|
|
276 |
"Created: / 19-07-2019 / 11:20:42 / Claus Gittinger"
|
3711
|
277 |
"Modified: / 19-07-2019 / 15:38:11 / Claus Gittinger"
|
3700
|
278 |
!
|
|
279 |
|
|
280 |
select:itemsLabel
|
|
281 |
"select an item by label,
|
|
282 |
allowed after moving to:
|
|
283 |
aComboBox
|
|
284 |
aSelectionInListView
|
|
285 |
"
|
|
286 |
|
|
287 |
<action>
|
|
288 |
|
|
289 |
|idx|
|
|
290 |
|
|
291 |
(lastComponent isKindOf:ComboView) ifTrue:[
|
|
292 |
"/ click on the menubutton
|
|
293 |
self movePointerToComponent:lastComponent menuButton.
|
|
294 |
self click:1 inComponent:lastComponent menuButton.
|
|
295 |
Delay waitForSeconds:0.3.
|
|
296 |
(idx := lastComponent list indexOf:itemsLabel ifAbsent:[nil]) isNil ifTrue:[
|
|
297 |
self error:'no such item in comboList: ',itemsLabel
|
|
298 |
].
|
|
299 |
lastComponent select:idx.
|
|
300 |
Delay waitForSeconds:0.3.
|
|
301 |
lastComponent shownMenu notNil ifTrue:[
|
|
302 |
lastComponent shownMenu hide.
|
|
303 |
].
|
|
304 |
^ self
|
|
305 |
].
|
|
306 |
self error:'cannot select this component'
|
|
307 |
|
|
308 |
"Created: / 19-07-2019 / 12:34:25 / Claus Gittinger"
|
|
309 |
"Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger"
|
|
310 |
!
|
|
311 |
|
|
312 |
selectIndex:itemsIndex
|
|
313 |
"select an item by index,
|
|
314 |
allowed after moving to:
|
|
315 |
aComboBox
|
|
316 |
aSelectionInListView
|
|
317 |
"
|
|
318 |
|
|
319 |
<action>
|
|
320 |
|
3716
|
321 |
self selectIndex:itemsIndex in:lastComponent
|
|
322 |
|
|
323 |
"Created: / 19-07-2019 / 14:20:11 / Claus Gittinger"
|
|
324 |
"Modified: / 19-07-2019 / 21:59:36 / Claus Gittinger"
|
|
325 |
!
|
3711
|
326 |
|
3716
|
327 |
selectIndex:itemsIndex in:widgetArg
|
|
328 |
"select an item by index,
|
|
329 |
allowed after moving to:
|
|
330 |
aComboBox
|
|
331 |
aSelectionInListView
|
|
332 |
"
|
|
333 |
|
|
334 |
<action>
|
|
335 |
|
|
336 |
|widget y offset possibleWidgets|
|
|
337 |
|
|
338 |
(widget := widgetArg) isScrollWrapper ifTrue:[
|
3711
|
339 |
widget := widget scrolledView
|
|
340 |
].
|
|
341 |
|
|
342 |
(widget isKindOf:ComboView) ifTrue:[
|
3700
|
343 |
"/ click on the menubutton
|
3711
|
344 |
self movePointerToComponent:widget menuButton.
|
|
345 |
self click:1 inComponent:widget menuButton.
|
3700
|
346 |
Delay waitForSeconds:0.5.
|
3711
|
347 |
widget select:itemsIndex.
|
3700
|
348 |
Delay waitForSeconds:0.5.
|
|
349 |
self halt.
|
|
350 |
^ self
|
|
351 |
].
|
3711
|
352 |
(widget isKindOf:SelectionInListView) ifTrue:[
|
3716
|
353 |
(widget isLineVisible:itemsIndex) ifFalse:[
|
|
354 |
widget scrollToLine:itemsIndex
|
|
355 |
].
|
3711
|
356 |
"/ click on the item
|
|
357 |
y := widget yOfLine:itemsIndex.
|
|
358 |
offset := (widget width // 2) @ y.
|
|
359 |
self movePointerToComponent:widget offset:offset.
|
|
360 |
widget simulateButtonPress:1 at:offset sendDisplayEvent:false.
|
|
361 |
Delay waitForSeconds:(self clickTime).
|
|
362 |
widget simulateButtonRelease:1 at:offset sendDisplayEvent:false.
|
|
363 |
Delay waitForSeconds:0.5.
|
|
364 |
^ self
|
3716
|
365 |
].
|
|
366 |
(widget isKindOf:SelectionInListModelView) ifTrue:[
|
|
367 |
(widget isLineVisible:itemsIndex) ifFalse:[
|
|
368 |
widget scrollToLine:itemsIndex
|
|
369 |
].
|
|
370 |
y := widget yVisibleOfLine:itemsIndex.
|
|
371 |
offset := (widget width // 2) @ y.
|
|
372 |
self movePointerToComponent:widget offset:offset.
|
|
373 |
widget simulateButtonPress:1 at:offset sendDisplayEvent:false.
|
|
374 |
Delay waitForSeconds:(self clickTime).
|
|
375 |
widget simulateButtonRelease:1 at:offset sendDisplayEvent:false.
|
|
376 |
Delay waitForSeconds:0.5.
|
|
377 |
^ self
|
|
378 |
].
|
|
379 |
|
|
380 |
"/ none of it - see what is in there
|
|
381 |
possibleWidgets := OrderedCollection new.
|
|
382 |
widget allSubViewsDo:[:each |
|
|
383 |
((each isKindOf:ComboView)
|
|
384 |
or:[(each isKindOf:SelectionInListView)
|
|
385 |
or:[(each isKindOf:SelectionInListModelView)
|
|
386 |
]]) ifTrue:[
|
|
387 |
possibleWidgets add:each
|
|
388 |
]
|
|
389 |
].
|
|
390 |
possibleWidgets size == 1 ifTrue:[
|
|
391 |
self selectIndex:itemsIndex in:(possibleWidgets first).
|
|
392 |
^ self
|
3711
|
393 |
].
|
3716
|
394 |
|
3700
|
395 |
self error:'cannot select this component'
|
|
396 |
|
3716
|
397 |
"Created: / 19-07-2019 / 21:59:15 / Claus Gittinger"
|
|
398 |
"Modified: / 20-07-2019 / 07:57:41 / Claus Gittinger"
|
3711
|
399 |
!
|
|
400 |
|
|
401 |
type:aString
|
|
402 |
"enter text into the last component"
|
|
403 |
|
|
404 |
<action>
|
|
405 |
|
|
406 |
lastComponent simulateTextInput:aString at:(lastComponent extent // 2) sendDisplayEvent:false
|
|
407 |
|
|
408 |
"Created: / 19-07-2019 / 15:50:40 / Claus Gittinger"
|
3700
|
409 |
! !
|
|
410 |
|
|
411 |
!ShowMeHowItWorks methodsFor:'defaults'!
|
|
412 |
|
|
413 |
circlingCount
|
|
414 |
"circle around move-end position that many times"
|
|
415 |
|
|
416 |
^ 3
|
|
417 |
|
|
418 |
"Created: / 19-07-2019 / 13:03:45 / Claus Gittinger"
|
|
419 |
!
|
|
420 |
|
|
421 |
circlingRadius
|
|
422 |
"radius when circling"
|
|
423 |
|
|
424 |
^ 30 "/ pixels
|
|
425 |
|
|
426 |
"Created: / 19-07-2019 / 13:07:59 / Claus Gittinger"
|
|
427 |
!
|
|
428 |
|
|
429 |
circlingSpeed
|
|
430 |
"time per round when circling"
|
|
431 |
|
|
432 |
^ 0.3 seconds. "/ time per round
|
|
433 |
|
|
434 |
"Created: / 19-07-2019 / 13:02:34 / Claus Gittinger"
|
|
435 |
!
|
|
436 |
|
|
437 |
clickTime
|
|
438 |
"when clicking"
|
|
439 |
|
3711
|
440 |
^ self shortClickTime
|
3700
|
441 |
|
|
442 |
"Created: / 19-07-2019 / 13:17:20 / Claus Gittinger"
|
3711
|
443 |
"Modified: / 19-07-2019 / 15:21:51 / Claus Gittinger"
|
|
444 |
!
|
|
445 |
|
|
446 |
longClickTime
|
|
447 |
"when clicking buttons"
|
|
448 |
|
|
449 |
^ 500 milliseconds
|
|
450 |
|
|
451 |
"Created: / 19-07-2019 / 15:21:42 / Claus Gittinger"
|
3700
|
452 |
!
|
|
453 |
|
|
454 |
pointerAnimationDelay
|
|
455 |
^ 50 milliseconds. "/ 20 updates per second
|
|
456 |
|
|
457 |
"Created: / 19-07-2019 / 13:04:45 / Claus Gittinger"
|
|
458 |
!
|
|
459 |
|
|
460 |
pointerMoveSpeed
|
|
461 |
^ 400. "/ pixels per second
|
|
462 |
|
|
463 |
"Created: / 19-07-2019 / 13:05:40 / Claus Gittinger"
|
|
464 |
!
|
|
465 |
|
3717
|
466 |
pointerMoveSpeedFast
|
|
467 |
^ 600. "/ pixels per second
|
|
468 |
|
|
469 |
"Created: / 20-07-2019 / 08:13:58 / Claus Gittinger"
|
|
470 |
!
|
|
471 |
|
3711
|
472 |
shortClickTime
|
|
473 |
"when clicking"
|
|
474 |
|
|
475 |
^ 100 milliseconds
|
|
476 |
|
|
477 |
"Created: / 19-07-2019 / 15:21:29 / Claus Gittinger"
|
|
478 |
!
|
|
479 |
|
3700
|
480 |
talking
|
|
481 |
^ true
|
|
482 |
|
|
483 |
"Created: / 19-07-2019 / 14:31:14 / Claus Gittinger"
|
|
484 |
! !
|
|
485 |
|
|
486 |
!ShowMeHowItWorks methodsFor:'helper'!
|
|
487 |
|
3711
|
488 |
componentNamed:componentName
|
|
489 |
"retrieve a component by name or report an error if not found"
|
|
490 |
|
|
491 |
|component|
|
|
492 |
|
|
493 |
lastComponentName := componentName.
|
|
494 |
|
|
495 |
component := self findComponent:componentName.
|
|
496 |
component isNil ifTrue:[
|
|
497 |
self error:'no component found for: ',componentName.
|
|
498 |
].
|
|
499 |
lastComponent := component.
|
|
500 |
^ component
|
|
501 |
|
|
502 |
"Created: / 19-07-2019 / 15:37:35 / Claus Gittinger"
|
|
503 |
!
|
|
504 |
|
3700
|
505 |
findComponent:componentName
|
|
506 |
"find a component by name - in the active and possibly in any app"
|
|
507 |
|
3713
|
508 |
|component candidates|
|
3700
|
509 |
|
3713
|
510 |
application notNil ifTrue:[
|
|
511 |
component := self findComponent:componentName in:application.
|
3700
|
512 |
].
|
|
513 |
|
|
514 |
component isNil ifTrue:[
|
|
515 |
"/ search through all current applications
|
|
516 |
candidates := OrderedCollection new.
|
|
517 |
WindowGroup scheduledWindowGroups do:[:eachWG |
|
|
518 |
|eachApp|
|
|
519 |
|
|
520 |
(eachApp := eachWG application) notNil ifTrue:[
|
|
521 |
component := self findComponent:componentName in:eachApp.
|
|
522 |
component notNil ifTrue:[
|
|
523 |
candidates add:component
|
|
524 |
].
|
|
525 |
].
|
|
526 |
].
|
|
527 |
|
|
528 |
candidates size == 1 ifTrue:[
|
|
529 |
component := candidates first
|
|
530 |
] ifFalse:[
|
|
531 |
candidates notEmpty ifTrue:[
|
|
532 |
self error:'multiple components found by name: ',componentName.
|
|
533 |
]
|
|
534 |
].
|
|
535 |
].
|
|
536 |
^ component
|
|
537 |
|
|
538 |
"Created: / 19-07-2019 / 12:02:30 / Claus Gittinger"
|
3713
|
539 |
"Modified: / 19-07-2019 / 16:44:30 / Claus Gittinger"
|
3700
|
540 |
!
|
|
541 |
|
|
542 |
findComponent:componentName in:anApplication
|
|
543 |
|component componentNameSymbol foundByName foundByTitle foundByLabel|
|
|
544 |
|
|
545 |
(component := anApplication componentAt:componentName) notNil ifTrue:[^ component].
|
|
546 |
(componentNameSymbol := componentName asSymbolIfInterned) notNil ifTrue:[
|
|
547 |
(component := anApplication componentAt:componentNameSymbol) notNil ifTrue:[^ component].
|
|
548 |
].
|
|
549 |
|
|
550 |
"/ mhmh - search through all widgets of anApplication;
|
|
551 |
"/ maybe it was not created via the builder/spec,
|
|
552 |
"/ or it has changed its name.
|
|
553 |
"/ look for: widget's name, widget's title, widget's label
|
|
554 |
foundByName := OrderedCollection new.
|
|
555 |
foundByTitle := OrderedCollection new.
|
|
556 |
foundByLabel := OrderedCollection new.
|
|
557 |
|
|
558 |
anApplication window allSubViewsDo:[:each |
|
|
559 |
[
|
|
560 |
each name = componentName ifTrue:[ foundByName add:each ].
|
|
561 |
] on:MessageNotUnderstood do:[:ex | ].
|
|
562 |
[
|
|
563 |
each title = componentName ifTrue:[ foundByTitle add:each ].
|
|
564 |
] on:MessageNotUnderstood do:[:ex | ].
|
|
565 |
[
|
|
566 |
each label = componentName ifTrue:[ foundByLabel add:each ].
|
|
567 |
] on:MessageNotUnderstood do:[:ex | ].
|
|
568 |
].
|
|
569 |
foundByName notEmpty ifTrue:[
|
|
570 |
self assert:(foundByName size == 1) message:'multiple components found by name'.
|
|
571 |
^ foundByName first.
|
|
572 |
].
|
|
573 |
foundByTitle notEmpty ifTrue:[
|
|
574 |
self assert:(foundByTitle size == 1) message:'multiple components found by title'.
|
|
575 |
^ foundByTitle first.
|
|
576 |
].
|
|
577 |
foundByLabel notEmpty ifTrue:[
|
|
578 |
self assert:(foundByLabel size == 1) message:'multiple components found by label'.
|
|
579 |
^ foundByLabel first.
|
|
580 |
].
|
|
581 |
^ component
|
|
582 |
|
|
583 |
"Created: / 19-07-2019 / 11:36:21 / Claus Gittinger"
|
|
584 |
!
|
|
585 |
|
3715
|
586 |
randomThankYou
|
|
587 |
^ #(
|
|
588 |
'thank you, for watching'
|
|
589 |
'thank you for watching'
|
|
590 |
'thank you'
|
|
591 |
'have a good day'
|
|
592 |
'have fun'
|
|
593 |
'have fun with expecco'
|
|
594 |
'have fun with expecco, by the way: expecco comes from the latin word: peccare, which means: "to sin"'
|
|
595 |
'happy hacking'
|
|
596 |
'happy hacking, I hope you liked what you saw'
|
|
597 |
'hope you liked it'
|
|
598 |
'see you again'
|
|
599 |
'please give feedback, and let us know, if you liked it'
|
|
600 |
'if you have any questions, please contact exept'
|
|
601 |
'if you need more information, please take a look at the wiki'
|
|
602 |
) atRandom
|
|
603 |
|
|
604 |
"
|
|
605 |
OperatingSystem speak:'have fun with expecco'
|
3716
|
606 |
OperatingSystem speak:'have fun with expecco, by the way: expecco comes from the latin word: peccare, which means: to sin'
|
3715
|
607 |
OperatingSystem speak:'happy hacking, I hope you liked what you saw'
|
|
608 |
OperatingSystem speak:'please give feedback, and let us know, if you liked it'
|
|
609 |
OperatingSystem speak:'if you have any questions, please contact exept'
|
|
610 |
OperatingSystem speak:'if you need more information, please take a look at the wiki'
|
|
611 |
"
|
|
612 |
|
|
613 |
"Created: / 19-07-2019 / 21:39:18 / Claus Gittinger"
|
|
614 |
!
|
|
615 |
|
3700
|
616 |
tell:message
|
|
617 |
self talking ifTrue:[
|
|
618 |
OperatingSystem speak:message.
|
|
619 |
].
|
|
620 |
|
|
621 |
"Created: / 19-07-2019 / 14:57:50 / Claus Gittinger"
|
|
622 |
! !
|
|
623 |
|
|
624 |
!ShowMeHowItWorks methodsFor:'helpers - broken'!
|
|
625 |
|
|
626 |
click:buttonNr atPosition:position
|
|
627 |
"press-release at position"
|
|
628 |
|
|
629 |
|screen|
|
|
630 |
|
|
631 |
screen := Screen current.
|
|
632 |
|
|
633 |
screen setPointerPosition:position.
|
|
634 |
screen flush.
|
|
635 |
self click:buttonNr
|
|
636 |
|
|
637 |
"Created: / 19-07-2019 / 13:14:51 / Claus Gittinger"
|
|
638 |
! !
|
|
639 |
|
|
640 |
!ShowMeHowItWorks methodsFor:'helpers - mouse movement'!
|
|
641 |
|
|
642 |
circlePointerAroundComponent:component
|
|
643 |
"circle around it a few times"
|
|
644 |
|
|
645 |
self circlePointerAroundPosition:(component screenBounds center rounded)
|
|
646 |
|
|
647 |
"Created: / 19-07-2019 / 13:12:35 / Claus Gittinger"
|
|
648 |
!
|
|
649 |
|
|
650 |
circlePointerAroundPosition:position
|
|
651 |
"circle around it a few times"
|
|
652 |
|
|
653 |
|screen stepDelayTime numCircles circlingSpeed radius|
|
|
654 |
|
|
655 |
screen := Screen current.
|
|
656 |
|
|
657 |
circlingSpeed := self circlingSpeed. "/ time per round
|
|
658 |
numCircles := self circlingCount.
|
|
659 |
stepDelayTime := self pointerAnimationDelay. "/ update interval
|
|
660 |
|
|
661 |
radius := self circlingRadius.
|
|
662 |
|
|
663 |
"/ move it around a few times
|
|
664 |
1 to:numCircles do:[:round |
|
|
665 |
|n angle|
|
|
666 |
|
|
667 |
n := circlingSpeed / stepDelayTime. "/ nr of steps per circle
|
|
668 |
angle := 360 / n. "/ angle-delta per step
|
|
669 |
1 to:n do:[:step |
|
|
670 |
|a x y|
|
|
671 |
|
|
672 |
a := angle * step.
|
|
673 |
"/ clockwise starting above the center
|
|
674 |
x := position x + (radius * a degreesToRadians sin).
|
|
675 |
y := position y + (radius * a degreesToRadians cos).
|
|
676 |
"/ Transcript showCR:(x@y).
|
|
677 |
screen setPointerPosition:(x@y) rounded.
|
|
678 |
screen flush.
|
|
679 |
Delay waitFor:stepDelayTime.
|
|
680 |
].
|
|
681 |
"/ and back
|
|
682 |
screen setPointerPosition:position rounded.
|
|
683 |
screen flush.
|
|
684 |
Delay waitFor:stepDelayTime.
|
|
685 |
].
|
|
686 |
|
|
687 |
"Created: / 19-07-2019 / 13:12:40 / Claus Gittinger"
|
|
688 |
!
|
|
689 |
|
|
690 |
movePointerToComponent:aWidget
|
|
691 |
"move the mouse to aWidget's center"
|
|
692 |
|
|
693 |
self movePointerToPosition:(aWidget screenBounds center rounded).
|
|
694 |
|
|
695 |
"Created: / 19-07-2019 / 13:11:33 / Claus Gittinger"
|
|
696 |
!
|
|
697 |
|
3711
|
698 |
movePointerToComponent:aWidget offset:offset
|
|
699 |
"move the mouse to position inside aWidget's"
|
|
700 |
|
|
701 |
self movePointerToPosition:(aWidget screenBounds origin + offset) rounded.
|
|
702 |
|
|
703 |
"Created: / 19-07-2019 / 16:18:58 / Claus Gittinger"
|
|
704 |
!
|
|
705 |
|
3717
|
706 |
movePointerToComponent:aWidget speed:pixelsPerSecond
|
|
707 |
"move the mouse to aWidget's center"
|
|
708 |
|
|
709 |
self movePointerToPosition:(aWidget screenBounds center rounded) speed:pixelsPerSecond.
|
|
710 |
|
|
711 |
"Created: / 20-07-2019 / 08:12:49 / Claus Gittinger"
|
|
712 |
!
|
|
713 |
|
3700
|
714 |
movePointerToPosition:newPosition
|
|
715 |
"move the mouse to newPosition"
|
3717
|
716 |
|
|
717 |
self movePointerToPosition:newPosition speed:self pointerMoveSpeed
|
|
718 |
|
|
719 |
"Created: / 19-07-2019 / 12:57:30 / Claus Gittinger"
|
|
720 |
"Modified: / 20-07-2019 / 08:12:34 / Claus Gittinger"
|
|
721 |
!
|
|
722 |
|
|
723 |
movePointerToPosition:newPosition speed:pixelsPerSecond
|
|
724 |
"move the mouse to newPosition"
|
3700
|
725 |
|
|
726 |
|screen distance start numSteps moveTime stepDelayTime delta|
|
|
727 |
|
|
728 |
screen := Screen current.
|
|
729 |
start := screen pointerPosition.
|
|
730 |
|
|
731 |
distance := start dist:newPosition.
|
3717
|
732 |
moveTime := (distance / pixelsPerSecond) seconds. "/ time to move
|
|
733 |
stepDelayTime := self pointerAnimationDelay. "/ update every 50ms
|
3700
|
734 |
|
|
735 |
numSteps := moveTime / stepDelayTime.
|
|
736 |
numSteps = 0 ifTrue:[
|
|
737 |
"/ already there
|
|
738 |
^ self
|
|
739 |
].
|
|
740 |
|
|
741 |
delta := (newPosition - start) / numSteps.
|
|
742 |
1 to:numSteps do:[:step |
|
|
743 |
|p|
|
|
744 |
|
|
745 |
p := (start + (delta * step)) rounded.
|
|
746 |
"/ Transcript showCR:p.
|
|
747 |
screen setPointerPosition:p.
|
|
748 |
screen flush.
|
|
749 |
Delay waitFor:stepDelayTime.
|
|
750 |
].
|
|
751 |
|
3717
|
752 |
"Created: / 20-07-2019 / 08:12:07 / Claus Gittinger"
|
3711
|
753 |
! !
|
|
754 |
|
|
755 |
!ShowMeHowItWorks methodsFor:'menu actions - mouse buttons'!
|
|
756 |
|
|
757 |
click:buttonNr inComponent:component
|
|
758 |
"press-release in a component"
|
|
759 |
|
|
760 |
|t|
|
|
761 |
|
|
762 |
t := self shortClickTime.
|
|
763 |
(component isKindOf:Button) ifTrue:[
|
|
764 |
t := self longClickTime
|
|
765 |
].
|
|
766 |
self click:buttonNr inComponent:component clickTime:t
|
|
767 |
|
|
768 |
"Created: / 19-07-2019 / 13:18:27 / Claus Gittinger"
|
|
769 |
"Modified: / 19-07-2019 / 15:22:47 / Claus Gittinger"
|
|
770 |
!
|
|
771 |
|
|
772 |
click:buttonNr inComponent:component clickTime:clickTime
|
|
773 |
"press-release in a component"
|
|
774 |
|
|
775 |
component simulateButtonPress:buttonNr at:(component extent // 2) sendDisplayEvent:false.
|
|
776 |
Delay waitForSeconds:clickTime.
|
|
777 |
component simulateButtonRelease:buttonNr at:(component extent // 2) sendDisplayEvent:false.
|
|
778 |
|
|
779 |
"/ self click:buttonNr atPosition:(component extent // 2)
|
|
780 |
|
|
781 |
"Created: / 19-07-2019 / 15:21:05 / Claus Gittinger"
|
3700
|
782 |
!
|
|
783 |
|
|
784 |
press:buttonNr
|
|
785 |
"press at the current position"
|
|
786 |
|
|
787 |
|position screen x y|
|
|
788 |
|
|
789 |
screen := Screen current.
|
|
790 |
position := screen pointerPosition.
|
|
791 |
x := position x.
|
|
792 |
y := position y.
|
|
793 |
|
|
794 |
self movePointerToPosition:position.
|
|
795 |
|
|
796 |
false "OperatingSystem isOSXlike" ifTrue:[
|
|
797 |
|osxPos|
|
|
798 |
|
|
799 |
osxPos := OperatingSystem getMousePosition.
|
|
800 |
x := osxPos x rounded.
|
|
801 |
y := osxPos y rounded.
|
|
802 |
OperatingSystem generateButtonEvent:buttonNr down:true x:x y:y.
|
|
803 |
^ self.
|
|
804 |
].
|
|
805 |
|
|
806 |
screen sendKeyOrButtonEvent:#buttonPress x:x y:y keyOrButton:buttonNr state:0 toViewId:(screen rootWindowId).
|
|
807 |
screen flush.
|
|
808 |
|
|
809 |
"Created: / 19-07-2019 / 13:52:38 / Claus Gittinger"
|
|
810 |
!
|
|
811 |
|
|
812 |
release:buttonNr
|
|
813 |
"press-release at the current position"
|
|
814 |
|
|
815 |
|position screen x y|
|
|
816 |
|
|
817 |
screen := Screen current.
|
|
818 |
position := screen pointerPosition.
|
|
819 |
x := position x.
|
|
820 |
y := position y.
|
|
821 |
|
|
822 |
self movePointerToPosition:position.
|
|
823 |
|
|
824 |
false "OperatingSystem isOSXlike" ifTrue:[
|
|
825 |
|osxPos|
|
|
826 |
|
|
827 |
osxPos := OperatingSystem getMousePosition.
|
|
828 |
x := osxPos x rounded.
|
|
829 |
y := osxPos y rounded.
|
|
830 |
OperatingSystem generateButtonEvent:buttonNr down:false x:x y:y.
|
|
831 |
^ self.
|
|
832 |
].
|
|
833 |
|
|
834 |
screen sendKeyOrButtonEvent:#buttonRelease x:x y:y keyOrButton:buttonNr state:0 toViewId:(screen rootWindowId).
|
|
835 |
screen flush.
|
|
836 |
|
|
837 |
"Created: / 19-07-2019 / 13:53:05 / Claus Gittinger"
|
|
838 |
! !
|
|
839 |
|
|
840 |
!ShowMeHowItWorks methodsFor:'running'!
|
|
841 |
|
3711
|
842 |
doCommand:op
|
|
843 |
|numArgs sel args method|
|
|
844 |
|
|
845 |
op isArray ifTrue:[
|
|
846 |
op first isArray ifTrue:[
|
|
847 |
self doStream:op readStream.
|
|
848 |
^ self.
|
|
849 |
].
|
|
850 |
|
|
851 |
"/ construct a selector from keyword parts at odd indices
|
|
852 |
sel := ((op with:(1 to:op size) select:[:el :idx | idx odd]) asStringWith:'') asSymbol.
|
|
853 |
"/ construct arg vector from parts at even indices
|
|
854 |
args := op with:(1 to:op size) select:[:el :idx | idx even].
|
|
855 |
] ifFalse:[
|
|
856 |
sel := op.
|
|
857 |
numArgs := sel argumentCount.
|
|
858 |
args := opStream next:numArgs.
|
|
859 |
].
|
|
860 |
|
|
861 |
(self respondsTo:sel) ifFalse:[
|
|
862 |
self error:'bad operation: ',sel
|
|
863 |
].
|
|
864 |
method := self class lookupMethodFor:sel.
|
|
865 |
(method hasAnnotation:#action) ifFalse:[self halt].
|
|
866 |
|
|
867 |
lastResult := self perform:sel withArguments:args.
|
|
868 |
^ lastResult
|
|
869 |
|
|
870 |
"<<END
|
|
871 |
ShowMeHowItWorks do:#(
|
|
872 |
showing: 'Choose the number of arguments'
|
|
873 |
do: (
|
|
874 |
moveTo: NumberOfArguments
|
|
875 |
select: '1'
|
|
876 |
)
|
|
877 |
showing: 'Click into the "receiver" field'
|
|
878 |
do: (
|
|
879 |
moveTo: ReceiverEditor
|
|
880 |
click: ReceiverEditor
|
|
881 |
)
|
|
882 |
showing: 'Enter a value (or expression) into "receiver" field'
|
|
883 |
do: (
|
|
884 |
enter: '100'
|
|
885 |
)
|
|
886 |
showing: 'Click into the "first argument" field'
|
|
887 |
do: (
|
|
888 |
moveTo: Arg1Editor
|
|
889 |
click: ReceiverEditor
|
|
890 |
)
|
|
891 |
showing: 'Enter a value (or expression) into "receiver" field'
|
|
892 |
do: (
|
|
893 |
enter: '100'
|
|
894 |
)
|
|
895 |
)
|
|
896 |
END"
|
|
897 |
|
|
898 |
"Created: / 19-07-2019 / 15:34:55 / Claus Gittinger"
|
|
899 |
!
|
|
900 |
|
3700
|
901 |
doStream:specStream
|
3715
|
902 |
|previousStream resources|
|
3700
|
903 |
|
3715
|
904 |
resources := self class classResources.
|
|
905 |
|
3700
|
906 |
previousStream := opStream.
|
|
907 |
[
|
|
908 |
opStream := specStream.
|
|
909 |
[opStream atEnd] whileFalse:[
|
|
910 |
self nextCommand.
|
|
911 |
Display shiftDown ifTrue:[
|
3715
|
912 |
self tell:(resources string:'you pressed the shift key, do you want to stop the show?').
|
|
913 |
(Dialog confirm:(resources stringWithCRs:'Stop the demonstration?'))
|
3714
|
914 |
ifTrue:[
|
3715
|
915 |
self tell:(resources string:'you stopped the show,').
|
|
916 |
self tell:(resources string:(self randomThankYou)).
|
3714
|
917 |
^ AbortOperationRequest raise
|
|
918 |
].
|
3700
|
919 |
].
|
|
920 |
].
|
|
921 |
] ensure:[
|
|
922 |
opStream := previousStream
|
|
923 |
].
|
|
924 |
|
|
925 |
"<<END
|
|
926 |
ShowMeHowItWorks do:#(
|
|
927 |
showing: 'Choose the number of arguments'
|
|
928 |
do: (
|
|
929 |
moveTo: NumberOfArguments
|
|
930 |
select: '1'
|
|
931 |
)
|
|
932 |
showing: 'Click into the "receiver" field'
|
|
933 |
do: (
|
|
934 |
moveTo: ReceiverEditor
|
|
935 |
click: ReceiverEditor
|
|
936 |
)
|
|
937 |
showing: 'Enter a value (or expression) into "receiver" field'
|
|
938 |
do: (
|
|
939 |
enter: '100'
|
|
940 |
)
|
|
941 |
showing: 'Click into the "first argument" field'
|
|
942 |
do: (
|
|
943 |
moveTo: Arg1Editor
|
|
944 |
click: ReceiverEditor
|
|
945 |
)
|
|
946 |
showing: 'Enter a value (or expression) into "receiver" field'
|
|
947 |
do: (
|
|
948 |
enter: '100'
|
|
949 |
)
|
|
950 |
)
|
|
951 |
END"
|
|
952 |
|
|
953 |
"Created: / 19-07-2019 / 10:52:24 / Claus Gittinger"
|
3715
|
954 |
"Modified: / 19-07-2019 / 21:41:43 / Claus Gittinger"
|
3700
|
955 |
!
|
|
956 |
|
|
957 |
nextCommand
|
3711
|
958 |
self doCommand:(opStream next).
|
3700
|
959 |
|
|
960 |
"<<END
|
|
961 |
ShowMeHowItWorks do:#(
|
|
962 |
showing: 'Choose the number of arguments'
|
|
963 |
do: (
|
|
964 |
moveTo: NumberOfArguments
|
|
965 |
select: '1'
|
|
966 |
)
|
|
967 |
showing: 'Click into the "receiver" field'
|
|
968 |
do: (
|
|
969 |
moveTo: ReceiverEditor
|
|
970 |
click: ReceiverEditor
|
|
971 |
)
|
|
972 |
showing: 'Enter a value (or expression) into "receiver" field'
|
|
973 |
do: (
|
|
974 |
enter: '100'
|
|
975 |
)
|
|
976 |
showing: 'Click into the "first argument" field'
|
|
977 |
do: (
|
|
978 |
moveTo: Arg1Editor
|
|
979 |
click: ReceiverEditor
|
|
980 |
)
|
|
981 |
showing: 'Enter a value (or expression) into "receiver" field'
|
|
982 |
do: (
|
|
983 |
enter: '100'
|
|
984 |
)
|
|
985 |
)
|
|
986 |
END"
|
|
987 |
|
|
988 |
"Created: / 19-07-2019 / 10:54:04 / Claus Gittinger"
|
3711
|
989 |
"Modified: / 19-07-2019 / 15:35:15 / Claus Gittinger"
|
3700
|
990 |
! !
|
|
991 |
|
|
992 |
!ShowMeHowItWorks class methodsFor:'documentation'!
|
|
993 |
|
|
994 |
version_CVS
|
|
995 |
^ '$Header$'
|
|
996 |
! !
|
|
997 |
|