author | Claus Gittinger <cg@exept.de> |
Mon, 14 Oct 2019 20:55:04 +0200 | |
changeset 3787 | 7b01435dcf25 |
parent 3784 | f6654cc10071 |
child 3790 | a28f8340a3eb |
permissions | -rw-r--r-- |
3711 | 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' |
3780 | 11 |
classVariableNames:'IntroShownCount DebugMode' |
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) |
|
69 |
(show: 'üben üben üben') |
|
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) |
88 |
(show: 'üben üben üben') |
|
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) |
|
110 |
(show: 'üben üben üben') |
|
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) |
|
130 |
(show: 'üben üben üben') |
|
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 |
||
450 |
|sourceComponent targetComponent idx yPos sourcePos sourcePosOnScreen |
|
451 |
targetPos targetPosOnScreen targetPosInSource| |
|
452 |
||
453 |
self assert:( #(top center bottom) includes:where). |
|
454 |
||
455 |
verifying ifTrue:[^ self]. |
|
456 |
||
457 |
targetComponent := self findComponent:targetComponentName. |
|
458 |
self assert:targetComponent notNil. |
|
459 |
||
460 |
((sourceComponent := lastComponent) isKindOf:ScrollableView) ifTrue:[ |
|
461 |
sourceComponent := sourceComponent scrolledView. |
|
462 |
]. |
|
463 |
||
464 |
(sourceComponent isKindOf:HierarchicalListView) ifTrue:[ |
|
465 |
where == #top ifTrue:[ |
|
466 |
targetPos := targetComponent topCenter. |
|
467 |
] ifFalse:[ |
|
468 |
where == #center ifTrue:[ |
|
469 |
targetPos := targetComponent center |
|
470 |
] ifFalse:[ |
|
471 |
where == #bottom ifTrue:[ |
|
472 |
targetPos := targetComponent bottomCenter - (0 @ 1) |
|
473 |
]. |
|
474 |
]. |
|
475 |
]. |
|
476 |
||
477 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[ |
|
478 |
idx := itemsIndexOrLabelOrPattern |
|
479 |
] ifFalse:[ |
|
480 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[ |
|
481 |
idx := sourceComponent indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string]. |
|
482 |
] ifFalse:[ |
|
483 |
idx := sourceComponent indexOfElementForWhich:[:el | el label string = itemsIndexOrLabelOrPattern]. |
|
484 |
]. |
|
485 |
idx == 0 ifTrue:[ |
|
486 |
self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern |
|
487 |
]. |
|
488 |
]. |
|
489 |
yPos := sourceComponent yVisibleOfLine:idx. |
|
490 |
self movePointerToComponent:sourceComponent rightOffset:(10 @ (yPos + 3)). |
|
491 |
Delay waitForSeconds:0.5. |
|
492 |
sourcePosOnScreen := Display pointerPosition. |
|
493 |
sourcePos := Display translatePoint:sourcePosOnScreen from:nil to:sourceComponent. |
|
494 |
||
495 |
targetPosOnScreen := Display translatePoint:targetPos from:targetComponent to:nil. |
|
496 |
targetPosInSource := Display translatePoint:targetPosOnScreen from:nil to:sourceComponent. |
|
497 |
||
498 |
sourceComponent simulateButtonPress:1 at:sourcePos sendDisplayEvent:true. |
|
499 |
Delay waitForSeconds:0.5. |
|
500 |
self movePointerToComponent:targetComponent offset:targetPos. |
|
501 |
sourceComponent simulateButtonMotion:1 to:targetPosInSource sendDisplayEvent:false. |
|
502 |
sourceComponent simulateButtonRelease:1 at:targetPosInSource sendDisplayEvent:false. |
|
503 |
self halt. |
|
504 |
sourceComponent simulateButtonMotion:1 to:targetPosInSource sendDisplayEvent:false. |
|
505 |
Delay waitForSeconds:0.5. |
|
506 |
sourceComponent simulateButtonRelease:1 at:targetPosInSource sendDisplayEvent:true. |
|
507 |
||
508 |
"/ self movePointerToComponent:targetComponent offset:targetPos. |
|
509 |
"/ Delay waitForSeconds:2. |
|
510 |
"/ self press:1. |
|
511 |
"/ Delay waitForSeconds:2. |
|
512 |
"/ self release:1. |
|
513 |
"/ Delay waitForSeconds:0.5. |
|
514 |
self halt. |
|
515 |
^ self |
|
516 |
]. |
|
517 |
||
518 |
self error:'cannot expand in this component' |
|
519 |
||
520 |
"Created: / 19-07-2019 / 12:34:25 / Claus Gittinger" |
|
521 |
"Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger" |
|
522 |
! |
|
523 |
||
524 |
expand:itemsIndexOrLabelOrPattern |
|
525 |
"expand an item in a treeView by label, |
|
526 |
allowed after moving to: |
|
527 |
aSelectionInHierarchyView |
|
528 |
" |
|
529 |
||
530 |
<action> |
|
531 |
||
532 |
|component| |
|
533 |
||
534 |
verifying ifTrue:[^ self]. |
|
535 |
||
536 |
((component := lastComponent) isKindOf:ScrollableView) ifTrue:[ |
|
537 |
component := component scrolledView. |
|
538 |
]. |
|
539 |
||
540 |
(component isKindOf:HierarchicalListView) ifTrue:[ |
|
541 |
|idx yPos| |
|
542 |
||
543 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[ |
|
544 |
idx := itemsIndexOrLabelOrPattern |
|
545 |
] ifFalse:[ |
|
546 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[ |
|
547 |
idx := component indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string]. |
|
548 |
] ifFalse:[ |
|
549 |
idx := component indexOfElementForWhich:[:el | el label string = itemsIndexOrLabelOrPattern]. |
|
550 |
]. |
|
551 |
idx == 0 ifTrue:[ |
|
552 |
self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern |
|
553 |
]. |
|
554 |
]. |
|
555 |
yPos := component yVisibleOfLine:idx. |
|
556 |
self movePointerToComponent:component offset:(0 @ (yPos + 3)). |
|
557 |
Delay waitForSeconds:0.5. |
|
558 |
(component listAt:idx) expand. |
|
559 |
^ self |
|
560 |
]. |
|
561 |
||
562 |
self error:'cannot expand in this component' |
|
563 |
||
564 |
"Created: / 19-07-2019 / 12:34:25 / Claus Gittinger" |
|
565 |
"Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger" |
|
566 |
! |
|
567 |
||
3711 | 568 |
fastMoveTo:componentName |
569 |
"move the mouse to componentName without circling" |
|
3700 | 570 |
|
571 |
<action> |
|
572 |
||
3711 | 573 |
|component| |
3700 | 574 |
|
3711 | 575 |
component := self componentNamed:componentName. |
3717 | 576 |
self movePointerToComponent:component speed:(self pointerMoveSpeedFast). |
3711 | 577 |
|
3727 | 578 |
" |
579 |
ShowMeHowItWorks basicNew fastMoveTo:'Classes' |
|
580 |
ShowMeHowItWorks basicNew fastMoveTo:'Klassen' |
|
581 |
" |
|
582 |
||
3711 | 583 |
"Created: / 19-07-2019 / 15:39:23 / Claus Gittinger" |
3717 | 584 |
"Modified: / 20-07-2019 / 08:14:16 / Claus Gittinger" |
3727 | 585 |
"Modified (comment): / 23-07-2019 / 09:33:31 / Claus Gittinger" |
3700 | 586 |
! |
587 |
||
588 |
moveTo:componentName |
|
589 |
"move the mouse to componentName, |
|
590 |
then circle around it a few times" |
|
591 |
||
592 |
<action> |
|
593 |
||
594 |
|component| |
|
595 |
||
3711 | 596 |
component := self componentNamed:componentName. |
3700 | 597 |
self movePointerToComponent:component. |
3776 | 598 |
Display ctrlDown ifTrue:[^ self]. |
3700 | 599 |
self circlePointerAroundComponent:component. |
600 |
||
601 |
"Created: / 19-07-2019 / 11:20:42 / Claus Gittinger" |
|
3711 | 602 |
"Modified: / 19-07-2019 / 15:38:11 / Claus Gittinger" |
3700 | 603 |
! |
604 |
||
3787 | 605 |
select:itemsIndexOrLabelOrPattern |
3700 | 606 |
"select an item by label, |
607 |
allowed after moving to: |
|
608 |
aComboBox |
|
609 |
aSelectionInListView |
|
610 |
" |
|
611 |
||
612 |
<action> |
|
613 |
||
3783 | 614 |
|idx component| |
3775 | 615 |
|
616 |
verifying ifTrue:[^ self]. |
|
617 |
||
3783 | 618 |
((component := lastComponent) isKindOf:ScrollableView) ifTrue:[ |
619 |
component := component scrolledView. |
|
620 |
]. |
|
621 |
||
622 |
(component isKindOf:ComboView) ifTrue:[ |
|
3700 | 623 |
"/ click on the menubutton |
3783 | 624 |
self movePointerToComponent:component menuButton. |
625 |
self click:1 inComponent:component menuButton. |
|
3700 | 626 |
Delay waitForSeconds:0.3. |
3787 | 627 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[ |
628 |
idx := itemsIndexOrLabelOrPattern |
|
629 |
] ifFalse:[ |
|
630 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[ |
|
631 |
idx := component list findFirst:[:lbl | itemsIndexOrLabelOrPattern match:lbl] |
|
632 |
] ifFalse:[ |
|
633 |
idx := component list indexOf:itemsIndexOrLabelOrPattern. |
|
634 |
]. |
|
635 |
idx == 0 ifTrue:[ |
|
636 |
self error:'no such item in comboList: ',itemsIndexOrLabelOrPattern |
|
637 |
]. |
|
3700 | 638 |
]. |
3783 | 639 |
component select:idx. |
3700 | 640 |
Delay waitForSeconds:0.3. |
3783 | 641 |
component shownMenu notNil ifTrue:[ |
642 |
component shownMenu hide. |
|
3700 | 643 |
]. |
644 |
^ self |
|
645 |
]. |
|
3783 | 646 |
(component isKindOf:HierarchicalListView) ifTrue:[ |
3787 | 647 |
|idx yPos| |
648 |
||
649 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[ |
|
650 |
idx := itemsIndexOrLabelOrPattern |
|
651 |
] ifFalse:[ |
|
652 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[ |
|
653 |
idx := component indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string]. |
|
654 |
] ifFalse:[ |
|
655 |
idx := component indexOfElementForWhich:[:el | el label string = itemsIndexOrLabelOrPattern]. |
|
3783 | 656 |
]. |
3787 | 657 |
idx == 0 ifTrue:[ |
658 |
self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern |
|
659 |
]. |
|
660 |
]. |
|
661 |
yPos := component yVisibleOfLine:idx. |
|
662 |
self movePointerToComponent:component offset:(0 @ (yPos + 3)). |
|
663 |
component simulateButtonPress:1 at:(0 @ (yPos + 3)) sendDisplayEvent:false. |
|
664 |
Delay waitForSeconds:0.1. |
|
665 |
component simulateButtonRelease:1 at:(0 @ (yPos + 3)) sendDisplayEvent:false. |
|
666 |
"/ component selection:idx. |
|
3783 | 667 |
^ self |
668 |
]. |
|
669 |
||
3700 | 670 |
self error:'cannot select this component' |
671 |
||
672 |
"Created: / 19-07-2019 / 12:34:25 / Claus Gittinger" |
|
673 |
"Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger" |
|
674 |
! |
|
675 |
||
676 |
selectIndex:itemsIndex |
|
677 |
"select an item by index, |
|
678 |
allowed after moving to: |
|
679 |
aComboBox |
|
680 |
aSelectionInListView |
|
681 |
" |
|
682 |
||
683 |
<action> |
|
684 |
||
3716 | 685 |
self selectIndex:itemsIndex in:lastComponent |
686 |
||
687 |
"Created: / 19-07-2019 / 14:20:11 / Claus Gittinger" |
|
688 |
"Modified: / 19-07-2019 / 21:59:36 / Claus Gittinger" |
|
689 |
! |
|
3711 | 690 |
|
3716 | 691 |
selectIndex:itemsIndex in:widgetArg |
692 |
"select an item by index, |
|
693 |
allowed after moving to: |
|
694 |
aComboBox |
|
695 |
aSelectionInListView |
|
696 |
" |
|
697 |
||
698 |
<action> |
|
699 |
||
700 |
|widget y offset possibleWidgets| |
|
701 |
||
3775 | 702 |
verifying ifTrue:[^ self]. |
703 |
||
3716 | 704 |
(widget := widgetArg) isScrollWrapper ifTrue:[ |
3711 | 705 |
widget := widget scrolledView |
706 |
]. |
|
707 |
||
708 |
(widget isKindOf:ComboView) ifTrue:[ |
|
3700 | 709 |
"/ click on the menubutton |
3711 | 710 |
self movePointerToComponent:widget menuButton. |
711 |
self click:1 inComponent:widget menuButton. |
|
3700 | 712 |
Delay waitForSeconds:0.5. |
3711 | 713 |
widget select:itemsIndex. |
3700 | 714 |
Delay waitForSeconds:0.5. |
715 |
^ self |
|
716 |
]. |
|
3711 | 717 |
(widget isKindOf:SelectionInListView) ifTrue:[ |
3716 | 718 |
(widget isLineVisible:itemsIndex) ifFalse:[ |
719 |
widget scrollToLine:itemsIndex |
|
720 |
]. |
|
3711 | 721 |
"/ click on the item |
722 |
y := widget yOfLine:itemsIndex. |
|
723 |
offset := (widget width // 2) @ y. |
|
724 |
self movePointerToComponent:widget offset:offset. |
|
725 |
widget simulateButtonPress:1 at:offset sendDisplayEvent:false. |
|
726 |
Delay waitForSeconds:(self clickTime). |
|
727 |
widget simulateButtonRelease:1 at:offset sendDisplayEvent:false. |
|
728 |
Delay waitForSeconds:0.5. |
|
729 |
^ self |
|
3716 | 730 |
]. |
731 |
(widget isKindOf:SelectionInListModelView) ifTrue:[ |
|
732 |
(widget isLineVisible:itemsIndex) ifFalse:[ |
|
733 |
widget scrollToLine:itemsIndex |
|
734 |
]. |
|
735 |
y := widget yVisibleOfLine:itemsIndex. |
|
736 |
offset := (widget width // 2) @ y. |
|
737 |
self movePointerToComponent:widget offset:offset. |
|
738 |
widget simulateButtonPress:1 at:offset sendDisplayEvent:false. |
|
739 |
Delay waitForSeconds:(self clickTime). |
|
740 |
widget simulateButtonRelease:1 at:offset sendDisplayEvent:false. |
|
741 |
Delay waitForSeconds:0.5. |
|
742 |
^ self |
|
743 |
]. |
|
744 |
||
745 |
"/ none of it - see what is in there |
|
746 |
possibleWidgets := OrderedCollection new. |
|
747 |
widget allSubViewsDo:[:each | |
|
748 |
((each isKindOf:ComboView) |
|
749 |
or:[(each isKindOf:SelectionInListView) |
|
750 |
or:[(each isKindOf:SelectionInListModelView) |
|
751 |
]]) ifTrue:[ |
|
752 |
possibleWidgets add:each |
|
753 |
] |
|
754 |
]. |
|
755 |
possibleWidgets size == 1 ifTrue:[ |
|
756 |
self selectIndex:itemsIndex in:(possibleWidgets first). |
|
757 |
^ self |
|
3711 | 758 |
]. |
3716 | 759 |
|
3700 | 760 |
self error:'cannot select this component' |
761 |
||
3716 | 762 |
"Created: / 19-07-2019 / 21:59:15 / Claus Gittinger" |
763 |
"Modified: / 20-07-2019 / 07:57:41 / Claus Gittinger" |
|
3711 | 764 |
! |
765 |
||
766 |
type:aString |
|
767 |
"enter text into the last component" |
|
768 |
||
769 |
<action> |
|
770 |
||
3776 | 771 |
|t| |
772 |
||
3775 | 773 |
verifying ifTrue:[^ self]. |
774 |
||
3776 | 775 |
t := Display ctrlDown ifTrue:[0.05] ifFalse:[0.1]. |
776 |
lastComponent |
|
777 |
simulateTextInput:aString at:(lastComponent extent // 2) |
|
778 |
sendDisplayEvent:false keyPressTime:t |
|
3711 | 779 |
|
780 |
"Created: / 19-07-2019 / 15:50:40 / Claus Gittinger" |
|
3700 | 781 |
! ! |
782 |
||
783 |
!ShowMeHowItWorks methodsFor:'defaults'! |
|
784 |
||
785 |
circlingCount |
|
786 |
"circle around move-end position that many times" |
|
787 |
||
788 |
^ 3 |
|
789 |
||
790 |
"Created: / 19-07-2019 / 13:03:45 / Claus Gittinger" |
|
791 |
! |
|
792 |
||
793 |
circlingRadius |
|
794 |
"radius when circling" |
|
795 |
||
796 |
^ 30 "/ pixels |
|
797 |
||
798 |
"Created: / 19-07-2019 / 13:07:59 / Claus Gittinger" |
|
799 |
! |
|
800 |
||
801 |
circlingSpeed |
|
802 |
"time per round when circling" |
|
803 |
||
804 |
^ 0.3 seconds. "/ time per round |
|
805 |
||
806 |
"Created: / 19-07-2019 / 13:02:34 / Claus Gittinger" |
|
807 |
! |
|
808 |
||
809 |
clickTime |
|
810 |
"when clicking" |
|
811 |
||
3711 | 812 |
^ self shortClickTime |
3700 | 813 |
|
814 |
"Created: / 19-07-2019 / 13:17:20 / Claus Gittinger" |
|
3711 | 815 |
"Modified: / 19-07-2019 / 15:21:51 / Claus Gittinger" |
816 |
! |
|
817 |
||
818 |
longClickTime |
|
819 |
"when clicking buttons" |
|
820 |
||
821 |
^ 500 milliseconds |
|
822 |
||
823 |
"Created: / 19-07-2019 / 15:21:42 / Claus Gittinger" |
|
3700 | 824 |
! |
825 |
||
826 |
pointerAnimationDelay |
|
827 |
^ 50 milliseconds. "/ 20 updates per second |
|
828 |
||
829 |
"Created: / 19-07-2019 / 13:04:45 / Claus Gittinger" |
|
830 |
! |
|
831 |
||
832 |
pointerMoveSpeed |
|
833 |
^ 400. "/ pixels per second |
|
834 |
||
835 |
"Created: / 19-07-2019 / 13:05:40 / Claus Gittinger" |
|
836 |
! |
|
837 |
||
3717 | 838 |
pointerMoveSpeedFast |
839 |
^ 600. "/ pixels per second |
|
840 |
||
841 |
"Created: / 20-07-2019 / 08:13:58 / Claus Gittinger" |
|
842 |
! |
|
843 |
||
3711 | 844 |
shortClickTime |
845 |
"when clicking" |
|
846 |
||
847 |
^ 100 milliseconds |
|
848 |
||
849 |
"Created: / 19-07-2019 / 15:21:29 / Claus Gittinger" |
|
850 |
! |
|
851 |
||
3700 | 852 |
talking |
3780 | 853 |
"/ DebugMode := true |
3775 | 854 |
verifying ifTrue:[^ false]. |
3780 | 855 |
DebugMode == true ifTrue:[^ false]. |
3775 | 856 |
|
3727 | 857 |
"/ ^ Expecco::ExpeccoPreferences current speechEffectsEnabled |
3700 | 858 |
^ true |
859 |
||
860 |
"Created: / 19-07-2019 / 14:31:14 / Claus Gittinger" |
|
3727 | 861 |
"Modified (comment): / 23-07-2019 / 09:45:35 / Claus Gittinger" |
3700 | 862 |
! ! |
863 |
||
864 |
!ShowMeHowItWorks methodsFor:'helper'! |
|
865 |
||
3715 | 866 |
randomThankYou |
867 |
^ #( |
|
868 |
'thank you, for watching' |
|
869 |
'thank you for watching' |
|
870 |
'thank you' |
|
3775 | 871 |
'thanks' |
3715 | 872 |
'have a good day' |
3775 | 873 |
'have a nice day' |
3715 | 874 |
'have fun' |
875 |
'have fun with expecco' |
|
876 |
'have fun with expecco, by the way: expecco comes from the latin word: peccare, which means: "to sin"' |
|
877 |
'happy hacking' |
|
878 |
'happy hacking, I hope you liked what you saw' |
|
879 |
'hope you liked it' |
|
880 |
'see you again' |
|
3775 | 881 |
'be the source with you' |
882 |
'be the force with you' |
|
883 |
'may the force be with you' |
|
884 |
'may the source be with you' |
|
3715 | 885 |
'please give feedback, and let us know, if you liked it' |
886 |
'if you have any questions, please contact exept' |
|
887 |
'if you need more information, please take a look at the wiki' |
|
888 |
) atRandom |
|
889 |
||
890 |
" |
|
3775 | 891 |
OperatingSystem speak:'may the source be with you' |
3715 | 892 |
OperatingSystem speak:'have fun with expecco' |
3716 | 893 |
OperatingSystem speak:'have fun with expecco, by the way: expecco comes from the latin word: peccare, which means: to sin' |
3715 | 894 |
OperatingSystem speak:'happy hacking, I hope you liked what you saw' |
895 |
OperatingSystem speak:'please give feedback, and let us know, if you liked it' |
|
896 |
OperatingSystem speak:'if you have any questions, please contact exept' |
|
897 |
OperatingSystem speak:'if you need more information, please take a look at the wiki' |
|
898 |
" |
|
899 |
||
900 |
"Created: / 19-07-2019 / 21:39:18 / Claus Gittinger" |
|
901 |
! |
|
902 |
||
3700 | 903 |
tell:message |
904 |
self talking ifTrue:[ |
|
3728 | 905 |
OperatingSystem speak:message voiceName:voice. |
3700 | 906 |
]. |
907 |
||
908 |
"Created: / 19-07-2019 / 14:57:50 / Claus Gittinger" |
|
3728 | 909 |
"Modified: / 23-07-2019 / 10:28:02 / Claus Gittinger" |
3700 | 910 |
! ! |
911 |
||
912 |
!ShowMeHowItWorks methodsFor:'helpers - broken'! |
|
913 |
||
914 |
click:buttonNr atPosition:position |
|
915 |
"press-release at position" |
|
916 |
||
917 |
|screen| |
|
918 |
||
3775 | 919 |
verifying ifTrue:[^ self]. |
920 |
||
3700 | 921 |
screen := Screen current. |
922 |
||
923 |
screen setPointerPosition:position. |
|
924 |
screen flush. |
|
925 |
self click:buttonNr |
|
926 |
||
927 |
"Created: / 19-07-2019 / 13:14:51 / Claus Gittinger" |
|
928 |
! ! |
|
929 |
||
3727 | 930 |
!ShowMeHowItWorks methodsFor:'helpers - component search'! |
931 |
||
932 |
componentNamed:componentName |
|
933 |
"retrieve a component by name or report an error if not found. |
|
934 |
Can return either a view or a menu item" |
|
935 |
||
936 |
|component| |
|
937 |
||
938 |
lastComponentName := componentName. |
|
939 |
||
940 |
component := self findComponent:componentName. |
|
941 |
component isNil ifTrue:[ |
|
3784 | 942 |
self error:'no component found for: ',componentName mayProceed:verifying. |
943 |
^ nil |
|
3727 | 944 |
]. |
945 |
lastComponent := component. |
|
946 |
^ component |
|
947 |
||
948 |
"Created: / 19-07-2019 / 15:37:35 / Claus Gittinger" |
|
949 |
"Modified (comment): / 23-07-2019 / 09:31:53 / Claus Gittinger" |
|
950 |
! |
|
951 |
||
952 |
findComponent:componentName |
|
953 |
"find a component by name - in the active and possibly in any app. |
|
954 |
Can return either a view or a menu item" |
|
955 |
||
3787 | 956 |
^ self |
957 |
findComponent:componentName |
|
958 |
inAllApplications:true |
|
959 |
ifMultiple:[ |
|
960 |
self proceedableError:('multiple components found by name: ',componentName). |
|
961 |
nil |
|
3727 | 962 |
]. |
3780 | 963 |
|
3787 | 964 |
" |
965 |
ShowMeHowItWorks basicNew findComponent:'Classes' |
|
966 |
ShowMeHowItWorks basicNew findComponent:'Klassen' |
|
967 |
" |
|
3780 | 968 |
|
3787 | 969 |
"Created: / 19-07-2019 / 12:02:30 / Claus Gittinger" |
970 |
"Modified: / 19-07-2019 / 16:44:30 / Claus Gittinger" |
|
971 |
"Modified (comment): / 23-07-2019 / 09:32:44 / Claus Gittinger" |
|
972 |
! |
|
973 |
||
974 |
findComponent:componentName ifMultiple:exceptionalValue |
|
975 |
"find a component by name - in the active and possibly in any app. |
|
976 |
Can return either a view or a menu item" |
|
977 |
||
978 |
^ self |
|
979 |
findComponent:componentName |
|
980 |
inAllApplications:true |
|
981 |
ifMultiple:exceptionalValue |
|
3727 | 982 |
|
983 |
" |
|
984 |
ShowMeHowItWorks basicNew findComponent:'Classes' |
|
985 |
ShowMeHowItWorks basicNew findComponent:'Klassen' |
|
986 |
" |
|
987 |
||
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 |
||
3781 | 993 |
findComponent:componentNameOrPath in:anApplicationOrViewOrMenuItem |
3780 | 994 |
"find a component by name inside an app or inside a view. |
3727 | 995 |
Uses the NameKey of the spec, and optionally the label or modelKey. |
996 |
Can return either a view or a menu item" |
|
997 |
||
3780 | 998 |
|idx app window component componentNameSymbol foundByName foundByTitle foundByLabel item |
999 |
checkIfAllMenuItemsDoTheSame| |
|
1000 |
||
1001 |
(componentNameOrPath includes:$/) ifTrue:[ |
|
1002 |
(idx := componentNameOrPath indexOf:$/) ~~ 0 ifTrue:[ |
|
1003 |
|containerName restPath container| |
|
1004 |
||
1005 |
containerName := componentNameOrPath copyTo:idx-1. |
|
1006 |
restPath := componentNameOrPath copyFrom:idx+1. |
|
3781 | 1007 |
container := self findComponent:containerName in:anApplicationOrViewOrMenuItem. |
3780 | 1008 |
container isNil ifTrue:[ ^ nil ]. |
1009 |
^ self findComponent:restPath in:container |
|
1010 |
] |
|
1011 |
]. |
|
1012 |
||
1013 |
componentNameSymbol := componentNameOrPath asSymbolIfInterned ? componentNameOrPath. |
|
3727 | 1014 |
|
3781 | 1015 |
(app := anApplicationOrViewOrMenuItem) isView ifTrue:[ |
1016 |
window := anApplicationOrViewOrMenuItem. |
|
1017 |
app := anApplicationOrViewOrMenuItem application |
|
3727 | 1018 |
]. |
3781 | 1019 |
app isApplicationModel ifTrue:[ |
3780 | 1020 |
(component := app componentAt:componentNameSymbol) notNil ifTrue:[^ component]. |
1021 |
window := window ? app window. |
|
3781 | 1022 |
] ifFalse:[ |
1023 |
app isMenuItem ifTrue:[ |
|
1024 |
window := app submenu. |
|
1025 |
] |
|
1026 |
]. |
|
3727 | 1027 |
|
1028 |
"/ mhmh - search through all widgets of anApplication; |
|
1029 |
"/ maybe it was not created via the builder/spec, |
|
1030 |
"/ or it has changed its name. |
|
1031 |
"/ look for: widget's name, widget's title, widget's label |
|
1032 |
foundByName := OrderedCollection new. |
|
1033 |
foundByTitle := OrderedCollection new. |
|
1034 |
foundByLabel := OrderedCollection new. |
|
1035 |
||
3780 | 1036 |
window withAllSubViewsDo:[:each | |
3727 | 1037 |
|foundIt| |
1038 |
||
1039 |
foundIt := false. |
|
3780 | 1040 |
each shown ifTrue:[ |
3727 | 1041 |
[ |
3780 | 1042 |
each name = componentNameSymbol ifTrue:[ foundByName add:each. foundIt := true ]. |
3727 | 1043 |
] on:MessageNotUnderstood do:[:ex | ]. |
1044 |
foundIt ifFalse:[ |
|
1045 |
[ |
|
3780 | 1046 |
each title = componentNameSymbol ifTrue:[ foundByTitle add:each. foundIt := true ]. |
3727 | 1047 |
] on:MessageNotUnderstood do:[:ex | ]. |
1048 |
foundIt ifFalse:[ |
|
3780 | 1049 |
[ |
1050 |
each label = componentNameSymbol ifTrue:[ foundByLabel add:each. foundIt := true ]. |
|
1051 |
] on:MessageNotUnderstood do:[:ex | ]. |
|
1052 |
foundIt ifFalse:[ |
|
1053 |
each isMenu ifTrue:[ |
|
1054 |
(item := each detectItemForNameKey:componentNameSymbol) notNil ifTrue:[ |
|
1055 |
foundByName add:item. foundIt := true |
|
1056 |
]. |
|
3727 | 1057 |
foundIt ifFalse:[ |
3780 | 1058 |
(item := each detectItemForKey:componentNameSymbol) notNil ifTrue:[ |
1059 |
foundByName add:item. foundIt := true |
|
3727 | 1060 |
]. |
3780 | 1061 |
foundIt ifFalse:[ |
1062 |
(item := each detectItemForLabel:componentNameSymbol) notNil ifTrue:[ |
|
1063 |
foundByLabel add:item. foundIt := true |
|
1064 |
]. |
|
1065 |
]. |
|
3727 | 1066 |
]. |
3780 | 1067 |
]. |
1068 |
]. |
|
1069 |
] |
|
1070 |
]. |
|
3727 | 1071 |
]. |
1072 |
]. |
|
3780 | 1073 |
|
1074 |
"/ a check, if multiple menu items have the same action, then choose the first found |
|
1075 |
checkIfAllMenuItemsDoTheSame := |
|
1076 |
[:itemsFound | |
|
1077 |
|visibleItems| |
|
1078 |
||
1079 |
(itemsFound conform:[:each | each askFor:#isMenuItem]) ifTrue:[ |
|
1080 |
(itemsFound collect:[:item | item itemValue]) asSet size == 1 ifTrue:[ |
|
1081 |
"/ choose one which is visible, if possible |
|
1082 |
visibleItems := itemsFound select:[:item | item menuPanel shown]. |
|
1083 |
visibleItems notEmpty ifTrue:[ |
|
1084 |
^ visibleItems first |
|
1085 |
]. |
|
1086 |
^ itemsFound first. |
|
1087 |
]. |
|
1088 |
]. |
|
1089 |
]. |
|
1090 |
||
3727 | 1091 |
foundByName notEmpty ifTrue:[ |
3780 | 1092 |
checkIfAllMenuItemsDoTheSame value:foundByName. |
3727 | 1093 |
self assert:(foundByName size == 1) message:'multiple components found by name'. |
1094 |
^ foundByName first. |
|
1095 |
]. |
|
1096 |
foundByTitle notEmpty ifTrue:[ |
|
3780 | 1097 |
checkIfAllMenuItemsDoTheSame value:foundByTitle. |
3727 | 1098 |
self assert:(foundByTitle size == 1) message:'multiple components found by title'. |
1099 |
^ foundByTitle first. |
|
1100 |
]. |
|
1101 |
foundByLabel notEmpty ifTrue:[ |
|
3780 | 1102 |
checkIfAllMenuItemsDoTheSame value:foundByLabel. |
3727 | 1103 |
self assert:(foundByLabel size == 1) message:'multiple components found by label'. |
1104 |
^ foundByLabel first. |
|
1105 |
]. |
|
1106 |
^ component |
|
1107 |
||
1108 |
" |
|
1109 |
self basicNew findComponent:'Klassen' in:(Transcript topView) |
|
1110 |
" |
|
1111 |
||
1112 |
"Created: / 19-07-2019 / 11:36:21 / Claus Gittinger" |
|
1113 |
"Modified (comment): / 23-07-2019 / 09:31:34 / Claus Gittinger" |
|
3700 | 1114 |
! |
1115 |
||
3787 | 1116 |
findComponent:componentName inAllApplications:inAllApplicationsBool ifMultiple:exceptionalValue |
1117 |
"find a component by name - in the active and possibly in any app. |
|
1118 |
Can return either a view or a menu item" |
|
1119 |
||
1120 |
|component candidates modalGroup| |
|
1121 |
||
1122 |
application notNil ifTrue:[ |
|
1123 |
(component := self findComponent:componentName in:application) notNil ifTrue:[ |
|
1124 |
^ component. |
|
1125 |
]. |
|
1126 |
]. |
|
1127 |
candidates := OrderedCollection new. |
|
1128 |
||
1129 |
"/ is there a modal dialog open for the app? |
|
1130 |
(modalGroup := application windowGroup modalGroup) notNil ifTrue:[ |
|
1131 |
modalGroup topViews do:[:eachModalTopView | |
|
1132 |
component := self findComponent:componentName in:eachModalTopView. |
|
1133 |
component notNil ifTrue:[ |
|
1134 |
candidates add:component |
|
1135 |
]. |
|
1136 |
]. |
|
1137 |
candidates size == 1 ifTrue:[ |
|
1138 |
^ candidates first |
|
1139 |
]. |
|
1140 |
]. |
|
1141 |
inAllApplicationsBool ifTrue:[ |
|
1142 |
"/ search through all current applications |
|
1143 |
WindowGroup scheduledWindowGroups do:[:eachWG | |
|
1144 |
|eachApp| |
|
1145 |
||
1146 |
(eachApp := eachWG application) notNil ifTrue:[ |
|
1147 |
component := self findComponent:componentName in:eachApp. |
|
1148 |
component notNil ifTrue:[ |
|
1149 |
candidates add:component |
|
1150 |
]. |
|
1151 |
]. |
|
1152 |
]. |
|
1153 |
||
1154 |
candidates size == 1 ifTrue:[ |
|
1155 |
^ candidates first |
|
1156 |
]. |
|
1157 |
candidates notEmpty ifTrue:[ |
|
1158 |
"/ multiple elements (probably there are multiple topviews open... |
|
1159 |
"/ check the current windowGroup |
|
1160 |
^ exceptionalValue value |
|
1161 |
]. |
|
1162 |
]. |
|
1163 |
||
1164 |
^ nil |
|
1165 |
||
1166 |
" |
|
1167 |
ShowMeHowItWorks basicNew findComponent:'Classes' |
|
1168 |
ShowMeHowItWorks basicNew findComponent:'Klassen' |
|
1169 |
" |
|
1170 |
||
1171 |
"Created: / 19-07-2019 / 12:02:30 / Claus Gittinger" |
|
1172 |
"Modified: / 19-07-2019 / 16:44:30 / Claus Gittinger" |
|
1173 |
"Modified (comment): / 23-07-2019 / 09:32:44 / Claus Gittinger" |
|
1174 |
! |
|
1175 |
||
3780 | 1176 |
screenBoundsOfComponent:aWidgetOrMenuItem |
3727 | 1177 |
aWidgetOrMenuItem isView ifTrue:[ |
3780 | 1178 |
^ aWidgetOrMenuItem screenBounds |
1179 |
]. |
|
1180 |
(aWidgetOrMenuItem askFor:#isMenuItem) ifTrue:[ |
|
1181 |
|menuPanel menuBounds| |
|
3717 | 1182 |
|
3780 | 1183 |
aWidgetOrMenuItem isVisible ifTrue:[ |
1184 |
aWidgetOrMenuItem layout notNil ifTrue:[ |
|
1185 |
menuPanel := aWidgetOrMenuItem menuPanel. |
|
1186 |
menuPanel shown ifTrue:[ |
|
1187 |
menuBounds := menuPanel screenBounds. |
|
1188 |
^ aWidgetOrMenuItem layout + menuBounds origin |
|
1189 |
]. |
|
1190 |
]. |
|
1191 |
]. |
|
3700 | 1192 |
]. |
3780 | 1193 |
^ nil. |
3711 | 1194 |
! ! |
1195 |
||
3780 | 1196 |
!ShowMeHowItWorks methodsFor:'helpers - mouse buttons'! |
3711 | 1197 |
|
1198 |
click:buttonNr inComponent:component |
|
1199 |
"press-release in a component" |
|
1200 |
||
1201 |
|t| |
|
1202 |
||
1203 |
t := self shortClickTime. |
|
1204 |
(component isKindOf:Button) ifTrue:[ |
|
1205 |
t := self longClickTime |
|
1206 |
]. |
|
1207 |
self click:buttonNr inComponent:component clickTime:t |
|
1208 |
||
1209 |
"Created: / 19-07-2019 / 13:18:27 / Claus Gittinger" |
|
1210 |
"Modified: / 19-07-2019 / 15:22:47 / Claus Gittinger" |
|
1211 |
! |
|
1212 |
||
3780
604d8ffc8903
#FEATURE by exept
Claus Gittinger <cg@exept.de>
|