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