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