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