author | Claus Gittinger <cg@exept.de> |
Thu, 14 Nov 2019 12:10:56 +0100 | |
changeset 3818 | c3fd02d2d975 |
parent 3817 | 34cfc2fb2258 |
child 3819 | a2f591cb8405 |
permissions | -rw-r--r-- |
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 |
|
3795 | 10 |
closeApplicationWhenFinished defaultComponentWaitTime ui |
3803 | 11 |
theShowFile defaultElementTimeout applicationStack' |
3790 | 12 |
classVariableNames:'IntroShownCount DebugMode StartLabel' |
3700 | 13 |
poolDictionaries:'' |
14 |
category:'Interface-Help' |
|
15 |
! |
|
16 |
||
3796 | 17 |
Object subclass:#ItemInView |
18 |
instanceVariableNames:'view item boundsInView' |
|
19 |
classVariableNames:'' |
|
20 |
poolDictionaries:'' |
|
21 |
privateIn:ShowMeHowItWorks |
|
22 |
! |
|
23 |
||
3700 | 24 |
!ShowMeHowItWorks class methodsFor:'documentation'! |
25 |
||
26 |
documentation |
|
27 |
" |
|
3713 | 28 |
automatic presentations. |
29 |
To see how it works, open a methodFinder: |
|
30 |
MethodFinderWindow open |
|
31 |
and select its 'Show me how it works' item in the help menu. |
|
3700 | 32 |
|
33 |
[author:] |
|
34 |
Claus Gittinger |
|
35 |
" |
|
36 |
! |
|
37 |
||
38 |
example |
|
3713 | 39 |
MethodFinderWindow open. |
40 |
||
3700 | 41 |
ShowMeHowItWorks do:#( |
42 |
( showing: 'Choose the number of arguments' do:( |
|
43 |
moveTo: NumberOfArguments |
|
44 |
select: '1' |
|
45 |
)) |
|
46 |
(showing: 'Click into the "receiver" field' do:( |
|
47 |
moveTo: ReceiverEditor |
|
48 |
click: ReceiverEditor |
|
49 |
)) |
|
50 |
(showing: 'Enter a value (or expression) into "receiver" field' do:( |
|
51 |
enter: '100' |
|
52 |
)) |
|
53 |
(showing: 'Click into the "first argument" field' do:( |
|
54 |
moveTo: Arg1Editor |
|
55 |
click: ReceiverEditor |
|
56 |
)) |
|
57 |
(showing: 'Enter a value (or expression) into "receiver" field' do:( |
|
58 |
enter: '100' |
|
59 |
)) |
|
60 |
||
61 |
) |
|
3795 | 62 |
! |
63 |
||
64 |
scriptFormat |
|
65 |
" |
|
66 |
||
67 |
speaking: |
|
68 |
show: 'text' |
|
69 |
||
70 |
mouse movement: |
|
71 |
moveTo: '<component>' move there and circle around |
|
72 |
fastMoveTo: '<component>' move without circling |
|
73 |
(drag: '<fromComponent>' toComponent: '<toComponent>' dropAt:<pos> show:'text') |
|
74 |
pos is one of #topLeft, #topCenter, #topRght, #bottomLeft, #bottomCenter, #bottomRight |
|
75 |
text is spoken before the drop |
|
76 |
||
77 |
mouse actions: |
|
78 |
click |
|
79 |
click: buttonNumber |
|
80 |
select: itemsIndexOrLabelOrPattern |
|
81 |
itemsIndexOrLabelOrPattern can be an integer or text |
|
82 |
||
83 |
misc: |
|
84 |
wait: seconds just pause |
|
85 |
||
86 |
label: 'name' for debugging, presentation can be started at some |
|
87 |
label, by setting the StartLabel class variable |
|
88 |
||
89 |
(waitFor: '<component>' timeout:seconds) |
|
90 |
wait for a component to appear |
|
91 |
||
92 |
open 'nameOfAppModelClass' |
|
93 |
open an application (class) |
|
3799 | 94 |
|
95 |
raise 'application' |
|
96 |
raise 'masterApplication' |
|
97 |
||
3795 | 98 |
intro |
99 |
||
100 |
component naming: |
|
101 |
'<component>' can be: |
|
102 |
name of a component, as defined in the UI-spec's nameKey, |
|
103 |
helpKey |
|
104 |
title |
|
105 |
label |
|
106 |
||
107 |
a path like 'ProjectTree/ToolBar' will first find ProjectTrue, then ToolBar |
|
108 |
a menu item index like 'Toolbar/item[idx]' |
|
109 |
||
110 |
||
111 |
" |
|
3700 | 112 |
! ! |
113 |
||
114 |
!ShowMeHowItWorks class methodsFor:'running'! |
|
115 |
||
3775 | 116 |
application:anApplicationOrNilForAll do:specArray |
117 |
"spec contains a list of action commands (show: / moveTo: etc.)" |
|
118 |
||
119 |
self new |
|
120 |
application:anApplicationOrNilForAll; |
|
121 |
do:specArray |
|
122 |
||
123 |
" |
|
124 |
ShowMeHowItWorks do: |
|
125 |
#( |
|
126 |
(language: de) |
|
3792 | 127 |
(show: 'üben üben üben') |
3775 | 128 |
(wait: 0.5) |
129 |
(moveTo: NameOfComponent) |
|
130 |
) |
|
131 |
" |
|
132 |
||
133 |
"Created: / 19-07-2019 / 10:52:59 / Claus Gittinger" |
|
134 |
"Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger" |
|
135 |
! |
|
136 |
||
3795 | 137 |
application:anApplicationOrNilForAll doShowFile:aFilename |
138 |
"spec contains a list of action commands (show: / moveTo: etc.)" |
|
139 |
||
140 |
self new |
|
141 |
application:anApplicationOrNilForAll; |
|
142 |
doShowFile:aFilename |
|
143 |
||
144 |
" |
|
145 |
ShowMeHowItWorks do: |
|
146 |
#( |
|
147 |
(language: de) |
|
148 |
(show: 'üben üben üben') |
|
149 |
(wait: 0.5) |
|
150 |
(moveTo: NameOfComponent) |
|
151 |
) |
|
152 |
" |
|
153 |
||
154 |
"Created: / 19-07-2019 / 10:52:59 / Claus Gittinger" |
|
155 |
"Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger" |
|
156 |
! |
|
157 |
||
3700 | 158 |
do:specArray |
3728 | 159 |
"spec contains a list of action commands (show: / moveTo: etc.)" |
3727 | 160 |
|
3784 | 161 |
self do:specArray withUI:false |
3700 | 162 |
|
3727 | 163 |
" |
164 |
ShowMeHowItWorks do: |
|
165 |
#( |
|
3728 | 166 |
(language: de) |
3792 | 167 |
(show: 'üben üben üben') |
3728 | 168 |
(wait: 0.5) |
3727 | 169 |
(moveTo: NameOfComponent) |
170 |
) |
|
171 |
" |
|
172 |
||
173 |
"Created: / 19-07-2019 / 10:52:59 / Claus Gittinger" |
|
3728 | 174 |
"Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger" |
3784 | 175 |
! |
176 |
||
3787 | 177 |
do:specArray from:startLabelOrNil withUI:withUIBoolean |
178 |
"spec contains a list of action commands (show: / moveTo: etc.)" |
|
179 |
||
180 |
self new |
|
181 |
do:specArray |
|
182 |
from:startLabelOrNil |
|
183 |
withUI:withUIBoolean |
|
184 |
||
185 |
" |
|
186 |
ShowMeHowItWorks |
|
187 |
do:#( |
|
188 |
(language: de) |
|
3792 | 189 |
(show: 'üben üben üben') |
3787 | 190 |
(wait: 0.5) |
191 |
(moveTo: NameOfComponent) |
|
192 |
) |
|
193 |
withUI:true |
|
194 |
" |
|
195 |
||
196 |
"Created: / 19-07-2019 / 10:52:59 / Claus Gittinger" |
|
197 |
"Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger" |
|
198 |
! |
|
199 |
||
3784 | 200 |
do:specArray withUI:withUIBoolean |
201 |
"spec contains a list of action commands (show: / moveTo: etc.)" |
|
202 |
||
203 |
self new do:specArray withUI:withUIBoolean |
|
204 |
||
205 |
" |
|
206 |
ShowMeHowItWorks |
|
207 |
do:#( |
|
208 |
(language: de) |
|
3792 | 209 |
(show: 'üben üben üben') |
3784 | 210 |
(wait: 0.5) |
211 |
(moveTo: NameOfComponent) |
|
212 |
) |
|
213 |
withUI:true |
|
214 |
" |
|
215 |
||
216 |
"Created: / 19-07-2019 / 10:52:59 / Claus Gittinger" |
|
217 |
"Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger" |
|
3713 | 218 |
! ! |
219 |
||
220 |
!ShowMeHowItWorks methodsFor:'accessing'! |
|
221 |
||
3775 | 222 |
application:anApplication |
3803 | 223 |
"if set, only that application is presented (widget search is limited to that one)" |
3775 | 224 |
|
225 |
application := anApplication. |
|
3795 | 226 |
! |
227 |
||
228 |
setLanguage:lang |
|
229 |
voice := OperatingSystem bestVoiceForLanguage:lang. |
|
230 |
language := lang. |
|
231 |
||
232 |
"Created: / 23-07-2019 / 10:27:02 / Claus Gittinger" |
|
3700 | 233 |
! ! |
234 |
||
235 |
!ShowMeHowItWorks methodsFor:'commands'! |
|
236 |
||
3804 | 237 |
closeApplication |
238 |
<action> |
|
239 |
||
240 |
application closeRequest. |
|
241 |
! |
|
242 |
||
3798 | 243 |
freezePin:pinName ofStep:stepName with:freezeString |
244 |
<action> |
|
245 |
||
246 |
|diagramEditor pinPO| |
|
247 |
||
248 |
(diagramEditor := lastComponent) isScrollWrapper ifTrue:[ |
|
249 |
diagramEditor := lastComponent scrolledView |
|
250 |
]. |
|
3799 | 251 |
pinPO := self pinPOForPin:pinName ofStep:stepName. |
252 |
||
3798 | 253 |
diagramEditor selection:{ pinPO }. |
254 |
diagramEditor doubleClickOn:pinPO. |
|
255 |
self fastMoveTo:(lastComponentName,'/','EditField'). |
|
256 |
self click. |
|
3800 | 257 |
self clear. |
3798 | 258 |
self type:freezeString. |
259 |
self key:#Return. |
|
260 |
! |
|
261 |
||
3711 | 262 |
intro |
263 |
<action> |
|
3724 | 264 |
|
3775 | 265 |
verifying ifTrue:[^ self]. |
266 |
||
267 |
IntroShownCount := (IntroShownCount ? 0). |
|
268 |
||
3728 | 269 |
"/ only say this a few times.. |
270 |
IntroShownCount > 3 ifTrue:[^ self]. |
|
3775 | 271 |
IntroShownCount := IntroShownCount + 1. |
272 |
||
3795 | 273 |
language isNil ifTrue:[ |
274 |
self setLanguage:(Smalltalk language). |
|
275 |
]. |
|
3724 | 276 |
self tell:(self class classResources |
3733 | 277 |
string:'You can stop this show, by pressing the SHIFT key'). |
3711 | 278 |
|
279 |
"Created: / 19-07-2019 / 15:49:19 / Claus Gittinger" |
|
3733 | 280 |
"Modified: / 23-07-2019 / 11:06:13 / Claus Gittinger" |
3728 | 281 |
! |
282 |
||
3787 | 283 |
label:nameOfLabel |
284 |
<action> |
|
285 |
||
286 |
"/ skipped here; see goto |
|
287 |
! |
|
288 |
||
3728 | 289 |
language:lang |
290 |
<action> |
|
291 |
||
3795 | 292 |
self setLanguage:lang. |
3728 | 293 |
translate := false. |
294 |
||
295 |
"Created: / 23-07-2019 / 10:27:02 / Claus Gittinger" |
|
3711 | 296 |
! |
297 |
||
3780 | 298 |
open:applicationClassName |
299 |
<action> |
|
300 |
||
301 |
|appClass| |
|
302 |
||
303 |
(appClass := Smalltalk classNamed:applicationClassName) isNil ifTrue:[ |
|
304 |
self error:'no such application class' |
|
305 |
]. |
|
306 |
verifying ifFalse:[ |
|
307 |
application := appClass new openAndWaitUntilVisible. |
|
308 |
closeApplicationWhenFinished := true. |
|
309 |
]. |
|
310 |
||
311 |
"Created: / 19-07-2019 / 15:09:45 / Claus Gittinger" |
|
312 |
! |
|
313 |
||
3700 | 314 |
pause |
315 |
<action> |
|
316 |
||
3724 | 317 |
Dialog information:(self class classResources |
318 |
stringWithCRs:'Show Paused.\Click on "OK" to proceed') |
|
3700 | 319 |
|
320 |
"Created: / 19-07-2019 / 15:03:17 / Claus Gittinger" |
|
3711 | 321 |
"Modified: / 19-07-2019 / 16:13:33 / Claus Gittinger" |
3700 | 322 |
! |
323 |
||
3803 | 324 |
popApplication |
325 |
<action> |
|
326 |
||
327 |
"go back to the previous app" |
|
328 |
||
329 |
application := applicationStack removeLast. |
|
330 |
! |
|
331 |
||
332 |
pushApplication:newApplicationOrName |
|
333 |
<action> |
|
334 |
||
335 |
"goto another app, remembering where we were before" |
|
336 |
||
337 |
|newApplication| |
|
338 |
||
339 |
(newApplication := newApplicationOrName) isString ifTrue:[ |
|
340 |
newApplication := self findApplication:newApplicationOrName ifMultiple:nil. |
|
341 |
self assert: newApplication notNil. |
|
342 |
]. |
|
343 |
||
344 |
applicationStack isNil ifTrue:[applicationStack := OrderedCollection new]. |
|
345 |
||
346 |
applicationStack add:application. |
|
347 |
self application:newApplication. |
|
348 |
! |
|
349 |
||
3776 | 350 |
raise:what |
351 |
<action> |
|
352 |
||
353 |
verifying ifTrue:[^ self]. |
|
354 |
||
355 |
what == #application ifTrue:[ |
|
356 |
application topView raise. |
|
357 |
^ self |
|
358 |
]. |
|
359 |
what == #masterApplication ifTrue:[ |
|
360 |
application windowGroup isModal ifTrue:[ |
|
361 |
application windowGroup mainGroup topViews first raise |
|
362 |
] ifFalse:[ |
|
363 |
(application masterApplication ? application) topViews first raise. |
|
364 |
]. |
|
365 |
^ self |
|
366 |
]. |
|
367 |
self halt. |
|
368 |
! |
|
369 |
||
3798 | 370 |
selectPin:pinName ofStep:stepName |
371 |
<action> |
|
372 |
||
3800 | 373 |
|diagramEditor pinPO count| |
3798 | 374 |
|
375 |
(diagramEditor := lastComponent) isScrollWrapper ifTrue:[ |
|
376 |
diagramEditor := lastComponent scrolledView |
|
377 |
]. |
|
3800 | 378 |
|
379 |
count := 0. |
|
380 |
[ |
|
381 |
Delay waitForSeconds:0.1. |
|
382 |
pinPO := self pinPOForPin:pinName ofStep:stepName. |
|
383 |
] doWhile:[pinPO isNil and:[ (count := count+1) < 20]]. |
|
384 |
||
385 |
self movePointerToComponent:diagramEditor offset:(pinPO frame center). |
|
3799 | 386 |
diagramEditor selection:{ pinPO }. |
3798 | 387 |
! |
388 |
||
3711 | 389 |
show:message |
3714 | 390 |
"showing (and speak) some message." |
3711 | 391 |
|
392 |
<action> |
|
393 |
||
3776 | 394 |
self showing:message saying:nil do:nil |
3711 | 395 |
|
396 |
"Created: / 19-07-2019 / 15:59:18 / Claus Gittinger" |
|
3714 | 397 |
"Modified (comment): / 19-07-2019 / 18:54:36 / Claus Gittinger" |
398 |
! |
|
399 |
||
400 |
show:message for:seconds |
|
401 |
"showing (and speak) some message and wait for some time." |
|
402 |
||
403 |
<action> |
|
3780 | 404 |
|
405 |
DebugMode == true ifTrue:[^ self]. |
|
406 |
||
3714 | 407 |
self show:message. |
408 |
self wait:seconds. |
|
409 |
||
410 |
"Created: / 19-07-2019 / 18:54:20 / Claus Gittinger" |
|
3711 | 411 |
! |
412 |
||
3776 | 413 |
show:message saying:sentenceOrNil |
414 |
"showing (and speak) some message." |
|
415 |
||
416 |
<action> |
|
417 |
||
418 |
self showing:message saying:sentenceOrNil do:nil |
|
419 |
||
420 |
"Created: / 19-07-2019 / 15:59:18 / Claus Gittinger" |
|
421 |
"Modified (comment): / 19-07-2019 / 18:54:36 / Claus Gittinger" |
|
422 |
! |
|
423 |
||
424 |
show:message saying:sentenceOrNil for:seconds |
|
425 |
"showing (and speak) some message and wait for some time." |
|
426 |
||
427 |
<action> |
|
428 |
||
3780 | 429 |
DebugMode == true ifTrue:[^ self]. |
3776 | 430 |
self show:message saying:sentenceOrNil. |
431 |
self wait:seconds. |
|
432 |
||
433 |
"Created: / 19-07-2019 / 18:54:20 / Claus Gittinger" |
|
434 |
! |
|
435 |
||
3711 | 436 |
showing:message do:operationsOrNothing |
3714 | 437 |
"execute operationsOrNothing while showing (and speaking) some message." |
3700 | 438 |
|
439 |
<action> |
|
440 |
||
3776 | 441 |
self showing:message saying:nil do:operationsOrNothing |
442 |
! |
|
443 |
||
444 |
showing:message saying:sentenceOrNil do:operationsOrNothing |
|
445 |
"execute operationsOrNothing while showing (and speaking) some message." |
|
446 |
||
447 |
<action> |
|
448 |
||
3715 | 449 |
|xLatedMessage messageView talkDone| |
3700 | 450 |
|
3728 | 451 |
xLatedMessage := (translate and:[application notNil]) |
3803 | 452 |
ifTrue:[application resources stringWithCRs:message] |
453 |
ifFalse:[message withCRs]. |
|
3728 | 454 |
|
3711 | 455 |
self assert:(operationsOrNothing isNil or:[operationsOrNothing isSequenceable]). |
3700 | 456 |
|
3715 | 457 |
messageView := ActiveHelpView for:xLatedMessage. |
3700 | 458 |
"/ messageView shapeStyle:#cartoon. |
459 |
[ |
|
3804 | 460 |
|p top left bot right w h| |
461 |
||
462 |
w := messageView preferredExtent x. |
|
463 |
h := messageView preferredExtent y. |
|
464 |
||
465 |
p := Screen current pointerPosition. |
|
466 |
left := p x. top := p y. |
|
467 |
bot := top + h. right := left + w. |
|
468 |
||
469 |
messageView origin:(left @ top). |
|
3780 | 470 |
messageView makeFullyVisible. |
3700 | 471 |
messageView realize. |
472 |
||
473 |
self talking ifTrue:[ |
|
474 |
talkDone := Semaphore new. |
|
475 |
[ |
|
3815 | 476 |
|sentence| |
477 |
sentence := (sentenceOrNil ? xLatedMessage) copy withCRs replaceAny:c'\t' with:(Character space). |
|
3817 | 478 |
sentence := sentence copy withCRs replaceAny:c'\n\r' with:(Character space). |
479 |
self tell:sentence. |
|
3700 | 480 |
talkDone signal |
481 |
] fork. |
|
482 |
||
483 |
"/ |
|
484 |
"/ allow speaker some headoff |
|
3775 | 485 |
verifying ifFalse:[ |
486 |
Delay waitForSeconds:(xLatedMessage size / 15)+0.5. |
|
487 |
]. |
|
3700 | 488 |
]. |
489 |
||
3711 | 490 |
operationsOrNothing notEmptyOrNil ifTrue:[ |
491 |
self doStream:(operationsOrNothing readStream). |
|
492 |
]. |
|
3700 | 493 |
] ensure:[ |
494 |
messageView destroy |
|
495 |
]. |
|
496 |
self talking ifTrue:[ |
|
497 |
talkDone wait. |
|
498 |
]. |
|
499 |
||
500 |
"Created: / 19-07-2019 / 11:19:27 / Claus Gittinger" |
|
3728 | 501 |
"Modified: / 23-07-2019 / 10:52:30 / Claus Gittinger" |
502 |
! |
|
503 |
||
504 |
thankyou |
|
505 |
<action> |
|
506 |
||
507 |
self show:(self randomThankYou). |
|
508 |
||
509 |
"Created: / 23-07-2019 / 10:50:43 / Claus Gittinger" |
|
3700 | 510 |
! |
511 |
||
3799 | 512 |
timeout:seconds |
513 |
<action> |
|
514 |
||
515 |
defaultElementTimeout := seconds. |
|
516 |
||
517 |
"Created: / 23-07-2019 / 10:27:02 / Claus Gittinger" |
|
518 |
! |
|
519 |
||
3700 | 520 |
wait:seconds |
521 |
<action> |
|
522 |
||
3775 | 523 |
verifying ifTrue:[^ self]. |
3780 | 524 |
DebugMode == true ifTrue:[^ self]. |
3776 | 525 |
Display ctrlDown ifTrue:[^ self]. |
526 |
||
3700 | 527 |
Delay waitForSeconds:seconds |
528 |
||
529 |
"Created: / 19-07-2019 / 15:09:45 / Claus Gittinger" |
|
3780 | 530 |
! |
531 |
||
532 |
waitFor:componentName timeout:seconds |
|
533 |
<action> |
|
534 |
||
3799 | 535 |
|endTime component| |
3780 | 536 |
|
3781 | 537 |
verifying ifTrue:[^ self]. |
538 |
||
3799 | 539 |
lastComponentName := componentName. |
3780 | 540 |
endTime := Timestamp now + seconds. |
3787 | 541 |
[ |
3799 | 542 |
(component := self findComponent:componentName inAllApplications:true ifMultiple:nil) notNil ifTrue:[ |
543 |
lastComponent := component. |
|
3780 | 544 |
^ self |
545 |
]. |
|
3799 | 546 |
Delay waitForSeconds:0.1. |
3780 | 547 |
Timestamp now > endTime ifTrue:[ |
548 |
self error:('component %1 not present after %2' bindWith:componentName with:seconds) |
|
549 |
] |
|
550 |
] loop |
|
3700 | 551 |
! ! |
552 |
||
3711 | 553 |
!ShowMeHowItWorks methodsFor:'commands - checking'! |
554 |
||
555 |
isEmpty:componentName |
|
3799 | 556 |
"true if the addressed textview/field is empty. |
557 |
Leaves component in lastComponent" |
|
558 |
||
3711 | 559 |
<action> |
560 |
||
561 |
|component| |
|
562 |
||
563 |
component := self componentNamed:componentName. |
|
564 |
component isScrollWrapper ifTrue:[ component := component scrolledView ]. |
|
565 |
component isTextView ifTrue:[ |
|
566 |
^ component contents isEmptyOrNil |
|
567 |
]. |
|
3799 | 568 |
self error:'isEmpty: unhandled (non-text) component type: ',component displayString. |
3711 | 569 |
|
570 |
"Created: / 19-07-2019 / 15:33:47 / Claus Gittinger" |
|
571 |
! |
|
572 |
||
573 |
unless:query do:actions |
|
574 |
<action> |
|
575 |
||
576 |
|result| |
|
577 |
||
578 |
result := self doCommand:query. |
|
579 |
result ifFalse:[ |
|
580 |
self doCommand:actions |
|
581 |
]. |
|
582 |
||
583 |
"Created: / 19-07-2019 / 15:33:32 / Claus Gittinger" |
|
584 |
! ! |
|
585 |
||
586 |
!ShowMeHowItWorks methodsFor:'commands - mouse & keyboard'! |
|
587 |
||
3798 | 588 |
clear |
3799 | 589 |
"clear entry fields of last component" |
3798 | 590 |
|
591 |
<action> |
|
592 |
||
593 |
verifying ifTrue:[^ self]. |
|
594 |
||
595 |
lastComponent contents:nil |
|
596 |
! |
|
597 |
||
3711 | 598 |
click |
3799 | 599 |
"press-release in last component" |
3711 | 600 |
|
601 |
<action> |
|
602 |
||
603 |
^ self click:1 inComponent:lastComponent |
|
604 |
||
605 |
"Created: / 19-07-2019 / 16:11:03 / Claus Gittinger" |
|
606 |
! |
|
3700 | 607 |
|
608 |
click:buttonNr |
|
3799 | 609 |
"press-release in last component" |
3700 | 610 |
|
611 |
<action> |
|
612 |
||
3711 | 613 |
self assert:(buttonNr isInteger). |
614 |
^ self click:buttonNr inComponent:lastComponent |
|
3700 | 615 |
|
616 |
"Created: / 19-07-2019 / 13:21:20 / Claus Gittinger" |
|
3711 | 617 |
"Modified: / 19-07-2019 / 16:10:19 / Claus Gittinger" |
3700 | 618 |
! |
619 |
||
3800 | 620 |
click:buttonNr clickTime:t |
621 |
"press-release in last component" |
|
622 |
||
623 |
<action> |
|
624 |
||
625 |
self assert:(buttonNr isInteger). |
|
626 |
^ self click:buttonNr inComponent:lastComponent clickTime:t |
|
627 |
! |
|
628 |
||
3711 | 629 |
clickIn:componentName |
3799 | 630 |
"press-release. |
631 |
Leaves component in lastComponent" |
|
3711 | 632 |
|
633 |
<action> |
|
634 |
||
635 |
^ self click:1 inComponent:(self componentNamed:componentName) |
|
636 |
||
637 |
"Created: / 19-07-2019 / 16:09:58 / Claus Gittinger" |
|
638 |
! |
|
639 |
||
3787 | 640 |
drag:itemsIndexOrLabelOrPattern toComponent:targetComponentName dropAt:where |
641 |
"drag an item (by index or label) from the current treeView, |
|
642 |
into another component. |
|
643 |
where is one of: #top, #center or #bottom. |
|
644 |
allowed after moving to: |
|
645 |
aSelectionInHierarchyView |
|
646 |
" |
|
647 |
||
648 |
<action> |
|
649 |
||
3790 | 650 |
self drag:itemsIndexOrLabelOrPattern toComponent:targetComponentName dropAt:where show:nil |
651 |
! |
|
652 |
||
653 |
drag:itemsIndexOrLabelOrPattern toComponent:targetComponentName dropAt:where show:textWhenDroppingOrNil |
|
654 |
"drag an item (by index or label) from the current treeView, |
|
655 |
into another component. |
|
656 |
where is one of: #top, #center or #bottom. |
|
657 |
allowed after moving to: |
|
658 |
aSelectionInHierarchyView |
|
659 |
" |
|
660 |
||
661 |
<action> |
|
662 |
||
3787 | 663 |
|sourceComponent targetComponent idx yPos sourcePos sourcePosOnScreen |
3790 | 664 |
targetPos targetPosOnScreen targetPosInSource dNdMgr| |
3787 | 665 |
|
666 |
verifying ifTrue:[^ self]. |
|
667 |
||
668 |
targetComponent := self findComponent:targetComponentName. |
|
669 |
self assert:targetComponent notNil. |
|
670 |
||
671 |
((sourceComponent := lastComponent) isKindOf:ScrollableView) ifTrue:[ |
|
672 |
sourceComponent := sourceComponent scrolledView. |
|
673 |
]. |
|
674 |
||
3796 | 675 |
targetPos := self where:where inComponent:targetComponent. |
3790 | 676 |
|
677 |
(sourceComponent isKindOf:HierarchicalListView) ifTrue:[ |
|
3787 | 678 |
|
679 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[ |
|
680 |
idx := itemsIndexOrLabelOrPattern |
|
681 |
] ifFalse:[ |
|
682 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[ |
|
683 |
idx := sourceComponent indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string]. |
|
684 |
] ifFalse:[ |
|
685 |
idx := sourceComponent indexOfElementForWhich:[:el | el label string = itemsIndexOrLabelOrPattern]. |
|
686 |
]. |
|
687 |
idx == 0 ifTrue:[ |
|
688 |
self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern |
|
689 |
]. |
|
690 |
]. |
|
3796 | 691 |
|
3787 | 692 |
yPos := sourceComponent yVisibleOfLine:idx. |
693 |
self movePointerToComponent:sourceComponent rightOffset:(10 @ (yPos + 3)). |
|
694 |
Delay waitForSeconds:0.5. |
|
695 |
sourcePosOnScreen := Display pointerPosition. |
|
3796 | 696 |
sourcePos := Display translatePoint:sourcePosOnScreen fromView:nil toView:sourceComponent. |
697 |
||
698 |
targetPosOnScreen := Display translatePoint:targetPos fromView:targetComponent toView:nil. |
|
699 |
targetPosInSource := Display translatePoint:targetPosOnScreen fromView:nil toView:sourceComponent. |
|
3787 | 700 |
|
3796 | 701 |
sourceComponent simulateButtonPress:1 at:sourcePos sendDisplayEvent:false. |
702 |
sourceComponent simulateButtonPress:1 at:sourcePos sendDisplayEvent:true. |
|
703 |
Delay waitForSeconds:0.2. |
|
3787 | 704 |
|
3790 | 705 |
dNdMgr := sourceComponent startDragAt:sourcePos. |
706 |
||
707 |
textWhenDroppingOrNil notNil ifTrue:[ |
|
708 |
self show:textWhenDroppingOrNil. |
|
709 |
]. |
|
710 |
||
711 |
Delay waitForSeconds:1. |
|
3787 | 712 |
self movePointerToComponent:targetComponent offset:targetPos. |
3790 | 713 |
Delay waitForSeconds:1. |
714 |
dNdMgr buttonMotion:1 x:targetPos x y:targetPos y view:targetComponent. |
|
3787 | 715 |
|
3790 | 716 |
dNdMgr buttonRelease:1 x:targetPos x y:targetPos y view:targetComponent. |
3796 | 717 |
sourceComponent simulateButtonRelease:1 at:targetPos sendDisplayEvent:false. |
3787 | 718 |
^ self |
719 |
]. |
|
720 |
||
721 |
self error:'cannot expand in this component' |
|
722 |
||
723 |
"Created: / 19-07-2019 / 12:34:25 / Claus Gittinger" |
|
724 |
"Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger" |
|
725 |
! |
|
726 |
||
727 |
expand:itemsIndexOrLabelOrPattern |
|
728 |
"expand an item in a treeView by label, |
|
729 |
allowed after moving to: |
|
730 |
aSelectionInHierarchyView |
|
731 |
" |
|
732 |
||
733 |
<action> |
|
734 |
||
735 |
|component| |
|
736 |
||
737 |
verifying ifTrue:[^ self]. |
|
738 |
||
739 |
((component := lastComponent) isKindOf:ScrollableView) ifTrue:[ |
|
740 |
component := component scrolledView. |
|
741 |
]. |
|
742 |
||
743 |
(component isKindOf:HierarchicalListView) ifTrue:[ |
|
744 |
|idx yPos| |
|
745 |
||
746 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[ |
|
747 |
idx := itemsIndexOrLabelOrPattern |
|
748 |
] ifFalse:[ |
|
749 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[ |
|
750 |
idx := component indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string]. |
|
751 |
] ifFalse:[ |
|
752 |
idx := component indexOfElementForWhich:[:el | el label string = itemsIndexOrLabelOrPattern]. |
|
753 |
]. |
|
754 |
idx == 0 ifTrue:[ |
|
755 |
self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern |
|
756 |
]. |
|
757 |
]. |
|
758 |
yPos := component yVisibleOfLine:idx. |
|
759 |
self movePointerToComponent:component offset:(0 @ (yPos + 3)). |
|
760 |
Delay waitForSeconds:0.5. |
|
761 |
(component listAt:idx) expand. |
|
762 |
^ self |
|
763 |
]. |
|
764 |
||
765 |
self error:'cannot expand in this component' |
|
766 |
||
767 |
"Created: / 19-07-2019 / 12:34:25 / Claus Gittinger" |
|
768 |
"Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger" |
|
769 |
! |
|
770 |
||
3798 | 771 |
fastMoveRelativeX:dX y:dY |
772 |
"move the mouse to a new relative position" |
|
773 |
||
774 |
<action> |
|
775 |
||
776 |
|screen newPos currentPos| |
|
777 |
||
778 |
verifying ifTrue:[^ self]. |
|
779 |
||
780 |
screen := Screen current. |
|
781 |
currentPos := screen pointerPosition. |
|
782 |
newPos := currentPos + (dX @ dY). |
|
783 |
self fastMovePointerToScreenPosition:newPos |
|
784 |
! |
|
785 |
||
3711 | 786 |
fastMoveTo:componentName |
3799 | 787 |
"move the mouse to componentName without circling. |
788 |
Leaves component in lastComponent" |
|
3700 | 789 |
|
790 |
<action> |
|
791 |
||
3711 | 792 |
|component| |
3700 | 793 |
|
3711 | 794 |
component := self componentNamed:componentName. |
3717 | 795 |
self movePointerToComponent:component speed:(self pointerMoveSpeedFast). |
3711 | 796 |
|
3727 | 797 |
" |
798 |
ShowMeHowItWorks basicNew fastMoveTo:'Classes' |
|
799 |
ShowMeHowItWorks basicNew fastMoveTo:'Klassen' |
|
800 |
" |
|
801 |
||
3711 | 802 |
"Created: / 19-07-2019 / 15:39:23 / Claus Gittinger" |
3717 | 803 |
"Modified: / 20-07-2019 / 08:14:16 / Claus Gittinger" |
3727 | 804 |
"Modified (comment): / 23-07-2019 / 09:33:31 / Claus Gittinger" |
3700 | 805 |
! |
806 |
||
3798 | 807 |
key:aKeySymbol |
3799 | 808 |
"press/release a key in last component" |
3798 | 809 |
|
810 |
<action> |
|
811 |
||
812 |
|t| |
|
813 |
||
814 |
verifying ifTrue:[^ self]. |
|
815 |
||
816 |
t := Display ctrlDown ifTrue:[0.05] ifFalse:[0.1]. |
|
817 |
lastComponent |
|
818 |
simulateKey:aKeySymbol at:(lastComponent extent // 2) sendDisplayEvent:false keyPressTime:t |
|
819 |
||
820 |
"Created: / 19-07-2019 / 15:50:40 / Claus Gittinger" |
|
821 |
! |
|
822 |
||
3700 | 823 |
moveTo:componentName |
824 |
"move the mouse to componentName, |
|
3799 | 825 |
then circle around it a few times. |
826 |
Leaves component in lastComponent" |
|
3700 | 827 |
|
828 |
<action> |
|
829 |
||
830 |
|component| |
|
831 |
||
3711 | 832 |
component := self componentNamed:componentName. |
3700 | 833 |
self movePointerToComponent:component. |
3776 | 834 |
Display ctrlDown ifTrue:[^ self]. |
3700 | 835 |
self circlePointerAroundComponent:component. |
836 |
||
837 |
"Created: / 19-07-2019 / 11:20:42 / Claus Gittinger" |
|
3711 | 838 |
"Modified: / 19-07-2019 / 15:38:11 / Claus Gittinger" |
3700 | 839 |
! |
840 |
||
3795 | 841 |
press:buttonNr |
842 |
<action> |
|
843 |
||
3799 | 844 |
"press at the current position in last component" |
3795 | 845 |
|
846 |
self assert:(buttonNr isInteger). |
|
847 |
^ self press:buttonNr inComponent:lastComponent. |
|
848 |
||
849 |
"/ "press at the current position" |
|
850 |
"/ |
|
851 |
"/ |position screen x y| |
|
852 |
"/ |
|
853 |
"/ verifying ifTrue:[^ self]. |
|
854 |
"/ |
|
855 |
"/ screen := Screen current. |
|
856 |
"/ position := screen pointerPosition. |
|
857 |
"/ x := position x. |
|
858 |
"/ y := position y. |
|
859 |
"/ |
|
860 |
"/ "/ self movePointerToScreenPosition:position. |
|
861 |
"/ |
|
862 |
"/ false "OperatingSystem isOSXlike" ifTrue:[ |
|
863 |
"/ |osxPos| |
|
864 |
"/ |
|
865 |
"/ osxPos := OperatingSystem getMousePosition. |
|
866 |
"/ x := osxPos x rounded. |
|
867 |
"/ y := osxPos y rounded. |
|
868 |
"/ OperatingSystem generateButtonEvent:buttonNr down:true x:x y:y. |
|
869 |
"/ ^ self. |
|
870 |
"/ ]. |
|
871 |
"/ |
|
872 |
"/ screen sendKeyOrButtonEvent:#buttonPress x:x y:y keyOrButton:buttonNr state:0 toViewId:(screen rootWindowId). |
|
873 |
"/ screen flush. |
|
874 |
"/ |
|
875 |
"/ "Created: / 19-07-2019 / 13:52:38 / Claus Gittinger" |
|
876 |
"/ "Modified: / 23-07-2019 / 09:38:31 / Claus Gittinger" |
|
877 |
! |
|
878 |
||
879 |
release:buttonNr |
|
880 |
<action> |
|
881 |
||
3799 | 882 |
"release at the current position in last component" |
3795 | 883 |
|
884 |
<action> |
|
885 |
||
886 |
self assert:(buttonNr isInteger). |
|
887 |
^ self press:buttonNr inComponent:lastComponent. |
|
888 |
"/ |position screen x y| |
|
889 |
"/ |
|
890 |
"/ verifying ifTrue:[^ self]. |
|
891 |
"/ |
|
892 |
"/ screen := Screen current. |
|
893 |
"/ position := screen pointerPosition. |
|
894 |
"/ x := position x. |
|
895 |
"/ y := position y. |
|
896 |
"/ |
|
897 |
"/ self movePointerToScreenPosition:position. |
|
898 |
"/ |
|
899 |
"/ false "OperatingSystem isOSXlike" ifTrue:[ |
|
900 |
"/ |osxPos| |
|
901 |
"/ |
|
902 |
"/ osxPos := OperatingSystem getMousePosition. |
|
903 |
"/ x := osxPos x rounded. |
|
904 |
"/ y := osxPos y rounded. |
|
905 |
"/ OperatingSystem generateButtonEvent:buttonNr down:false x:x y:y. |
|
906 |
"/ ^ self. |
|
907 |
"/ ]. |
|
908 |
"/ |
|
909 |
"/ screen sendKeyOrButtonEvent:#buttonRelease x:x y:y keyOrButton:buttonNr state:0 toViewId:(screen rootWindowId). |
|
910 |
"/ screen flush. |
|
911 |
||
912 |
"Created: / 19-07-2019 / 13:53:05 / Claus Gittinger" |
|
913 |
"Modified: / 23-07-2019 / 09:38:38 / Claus Gittinger" |
|
914 |
! |
|
915 |
||
3818 | 916 |
scrollToEnd |
917 |
<action> |
|
918 |
||
919 |
|scrollWrapper| |
|
920 |
||
921 |
"/ look for a scrollable view along the superview hierarchy |
|
922 |
scrollWrapper := lastComponent |
|
923 |
allSuperViewsDetect:[:v | v isScrollWrapper] |
|
924 |
ifNone:nil. |
|
925 |
||
926 |
scrollWrapper isNil ifTrue:[ |
|
927 |
"/ look in subviews for the first scrollWrapper |
|
928 |
scrollWrapper := lastComponent |
|
929 |
allSubViewsDetect:[:v | v shown and:[v isScrollWrapper]] |
|
930 |
ifNone:nil. |
|
931 |
]. |
|
932 |
scrollWrapper notNil ifTrue:[ |
|
933 |
scrollWrapper scrollBar scrollToEnd |
|
934 |
]. |
|
935 |
! |
|
936 |
||
3787 | 937 |
select:itemsIndexOrLabelOrPattern |
3700 | 938 |
"select an item by label, |
939 |
allowed after moving to: |
|
3803 | 940 |
a ComboBox |
941 |
a SelectionInListView |
|
942 |
a NoteBook |
|
943 |
a DSVColumnView |
|
3700 | 944 |
" |
945 |
||
946 |
<action> |
|
947 |
||
3803 | 948 |
|idx component yPos tab| |
3775 | 949 |
|
950 |
verifying ifTrue:[^ self]. |
|
951 |
||
3783 | 952 |
((component := lastComponent) isKindOf:ScrollableView) ifTrue:[ |
953 |
component := component scrolledView. |
|
954 |
]. |
|
955 |
||
956 |
(component isKindOf:ComboView) ifTrue:[ |
|
3700 | 957 |
"/ click on the menubutton |
3783 | 958 |
self movePointerToComponent:component menuButton. |
959 |
self click:1 inComponent:component menuButton. |
|
3700 | 960 |
Delay waitForSeconds:0.3. |
3787 | 961 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[ |
962 |
idx := itemsIndexOrLabelOrPattern |
|
963 |
] ifFalse:[ |
|
964 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[ |
|
965 |
idx := component list findFirst:[:lbl | itemsIndexOrLabelOrPattern match:lbl] |
|
966 |
] ifFalse:[ |
|
967 |
idx := component list indexOf:itemsIndexOrLabelOrPattern. |
|
968 |
]. |
|
969 |
idx == 0 ifTrue:[ |
|
970 |
self error:'no such item in comboList: ',itemsIndexOrLabelOrPattern |
|
971 |
]. |
|
3700 | 972 |
]. |
3783 | 973 |
component select:idx. |
3700 | 974 |
Delay waitForSeconds:0.3. |
3783 | 975 |
component shownMenu notNil ifTrue:[ |
976 |
component shownMenu hide. |
|
3700 | 977 |
]. |
978 |
^ self |
|
979 |
]. |
|
3783 | 980 |
(component isKindOf:HierarchicalListView) ifTrue:[ |
3787 | 981 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[ |
982 |
idx := itemsIndexOrLabelOrPattern |
|
983 |
] ifFalse:[ |
|
984 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[ |
|
985 |
idx := component indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string]. |
|
986 |
] ifFalse:[ |
|
987 |
idx := component indexOfElementForWhich:[:el | el label string = itemsIndexOrLabelOrPattern]. |
|
3783 | 988 |
]. |
3787 | 989 |
idx == 0 ifTrue:[ |
990 |
self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern |
|
991 |
]. |
|
992 |
]. |
|
993 |
yPos := component yVisibleOfLine:idx. |
|
994 |
self movePointerToComponent:component offset:(0 @ (yPos + 3)). |
|
995 |
component simulateButtonPress:1 at:(0 @ (yPos + 3)) sendDisplayEvent:false. |
|
996 |
Delay waitForSeconds:0.1. |
|
997 |
component simulateButtonRelease:1 at:(0 @ (yPos + 3)) sendDisplayEvent:false. |
|
998 |
"/ component selection:idx. |
|
3783 | 999 |
^ self |
1000 |
]. |
|
3798 | 1001 |
(component isKindOf:SelectionInListModelView) ifTrue:[ |
1002 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[ |
|
1003 |
idx := itemsIndexOrLabelOrPattern |
|
1004 |
] ifFalse:[ |
|
1005 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[ |
|
1006 |
idx := component indexOfElementForWhich:[:el | el notNil and:[itemsIndexOrLabelOrPattern match:el string]]. |
|
1007 |
] ifFalse:[ |
|
1008 |
idx := component indexOfElementForWhich:[:el | el notNil and:[el string = itemsIndexOrLabelOrPattern]]. |
|
1009 |
]. |
|
1010 |
idx == 0 ifTrue:[ |
|
1011 |
self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern |
|
1012 |
]. |
|
1013 |
]. |
|
1014 |
yPos := component yVisibleOfLine:idx. |
|
1015 |
self movePointerToComponent:component offset:(0 @ (yPos + 3)). |
|
1016 |
component simulateButtonPress:1 at:(0 @ (yPos + 3)) sendDisplayEvent:false. |
|
1017 |
Delay waitForSeconds:0.1. |
|
1018 |
component simulateButtonRelease:1 at:(0 @ (yPos + 3)) sendDisplayEvent:false. |
|
1019 |
"/ component selection:idx. |
|
1020 |
^ self |
|
1021 |
]. |
|
1022 |
||
1023 |
(component isKindOf:ItemInView) ifTrue:[ |
|
1024 |
component isMenuItem ifTrue:[ |
|
1025 |
self movePointerToComponent:component. |
|
3803 | 1026 |
self click. |
1027 |
^ self |
|
3798 | 1028 |
]. |
1029 |
]. |
|
1030 |
||
3803 | 1031 |
(component isKindOf:NoteBookView) ifTrue:[ |
1032 |
(idx := itemsIndexOrLabelOrPattern) isInteger ifFalse:[ |
|
3814 | 1033 |
idx := component list |
1034 |
findFirst:[:eachNotebookTab| |
|
1035 |
eachNotebookTab label string = itemsIndexOrLabelOrPattern string |
|
1036 |
or:[ eachNotebookTab printableLabel string = itemsIndexOrLabelOrPattern string ] |
|
1037 |
]. |
|
1038 |
"/ idx := component indexOfTabNamed:itemsIndexOrLabelOrPattern |
|
3803 | 1039 |
]. |
1040 |
tab := component tabAtIndex:idx. |
|
1041 |
self movePointerToComponent:component offset:(tab layout center). |
|
1042 |
component selection:idx. |
|
1043 |
^ self |
|
1044 |
]. |
|
1045 |
(component isKindOf:DSVColumnView) ifTrue:[ |
|
1046 |
(idx := itemsIndexOrLabelOrPattern) isInteger ifFalse:[ |
|
1047 |
self halt. |
|
1048 |
]. |
|
1049 |
yPos := ((component yVisibleOfRowNr:idx) + (component yVisibleOfRowNr:idx+1)) // 2. |
|
1050 |
self movePointerToComponent:component offset:(1 @ yPos). |
|
1051 |
component selectRow:idx. |
|
1052 |
^ self |
|
1053 |
]. |
|
1054 |
||
1055 |
self error:('cannot select "%1" this component: %2' bindWith:itemsIndexOrLabelOrPattern with:component className) |
|
3700 | 1056 |
|
1057 |
"Created: / 19-07-2019 / 12:34:25 / Claus Gittinger" |
|
1058 |
"Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger" |
|
1059 |
! |
|
1060 |
||
3803 | 1061 |
selectComponent:componentName |
1062 |
"Leaves component in lastComponent without moving" |
|
1063 |
||
1064 |
<action> |
|
1065 |
||
1066 |
|component| |
|
1067 |
||
1068 |
component := self componentNamed:componentName. |
|
1069 |
! |
|
1070 |
||
3700 | 1071 |
selectIndex:itemsIndex |
1072 |
"select an item by index, |
|
1073 |
allowed after moving to: |
|
1074 |
aComboBox |
|
1075 |
aSelectionInListView |
|
1076 |
" |
|
1077 |
||
1078 |
<action> |
|
1079 |
||
3716 | 1080 |
self selectIndex:itemsIndex in:lastComponent |
1081 |
||
1082 |
"Created: / 19-07-2019 / 14:20:11 / Claus Gittinger" |
|
1083 |
"Modified: / 19-07-2019 / 21:59:36 / Claus Gittinger" |
|
1084 |
! |
|
3711 | 1085 |
|
3716 | 1086 |
selectIndex:itemsIndex in:widgetArg |
1087 |
"select an item by index, |
|
1088 |
allowed after moving to: |
|
1089 |
aComboBox |
|
1090 |
aSelectionInListView |
|
1091 |
" |
|
1092 |
||
1093 |
<action> |
|
1094 |
||
1095 |
|widget y offset possibleWidgets| |
|
1096 |
||
3775 | 1097 |
verifying ifTrue:[^ self]. |
1098 |
||
3716 | 1099 |
(widget := widgetArg) isScrollWrapper ifTrue:[ |
3711 | 1100 |
widget := widget scrolledView |
1101 |
]. |
|
1102 |
||
1103 |
(widget isKindOf:ComboView) ifTrue:[ |
|
3700 | 1104 |
"/ click on the menubutton |
3711 | 1105 |
self movePointerToComponent:widget menuButton. |
1106 |
self click:1 inComponent:widget menuButton. |
|
3700 | 1107 |
Delay waitForSeconds:0.5. |
3711 | 1108 |
widget select:itemsIndex. |
3700 | 1109 |
Delay waitForSeconds:0.5. |
1110 |
^ self |
|
1111 |
]. |
|
3711 | 1112 |
(widget isKindOf:SelectionInListView) ifTrue:[ |
3716 | 1113 |
(widget isLineVisible:itemsIndex) ifFalse:[ |
1114 |
widget scrollToLine:itemsIndex |
|
1115 |
]. |
|
3711 | 1116 |
"/ click on the item |
1117 |
y := widget yOfLine:itemsIndex. |
|
1118 |
offset := (widget width // 2) @ y. |
|
1119 |
self movePointerToComponent:widget offset:offset. |
|
1120 |
widget simulateButtonPress:1 at:offset sendDisplayEvent:false. |
|
1121 |
Delay waitForSeconds:(self clickTime). |
|
1122 |
widget simulateButtonRelease:1 at:offset sendDisplayEvent:false. |
|
1123 |
Delay waitForSeconds:0.5. |
|
1124 |
^ self |
|
3716 | 1125 |
]. |
1126 |
(widget isKindOf:SelectionInListModelView) ifTrue:[ |
|
1127 |
(widget isLineVisible:itemsIndex) ifFalse:[ |
|
1128 |
widget scrollToLine:itemsIndex |
|
1129 |
]. |
|
1130 |
y := widget yVisibleOfLine:itemsIndex. |
|
1131 |
offset := (widget width // 2) @ y. |
|
1132 |
self movePointerToComponent:widget offset:offset. |
|
1133 |
widget simulateButtonPress:1 at:offset sendDisplayEvent:false. |
|
1134 |
Delay waitForSeconds:(self clickTime). |
|
1135 |
widget simulateButtonRelease:1 at:offset sendDisplayEvent:false. |
|
1136 |
Delay waitForSeconds:0.5. |
|
1137 |
^ self |
|
1138 |
]. |
|
1139 |
||
1140 |
"/ none of it - see what is in there |
|
1141 |
possibleWidgets := OrderedCollection new. |
|
1142 |
widget allSubViewsDo:[:each | |
|
1143 |
((each isKindOf:ComboView) |
|
1144 |
or:[(each isKindOf:SelectionInListView) |
|
1145 |
or:[(each isKindOf:SelectionInListModelView) |
|
1146 |
]]) ifTrue:[ |
|
1147 |
possibleWidgets add:each |
|
1148 |
] |
|
1149 |
]. |
|
1150 |
possibleWidgets size == 1 ifTrue:[ |
|
1151 |
self selectIndex:itemsIndex in:(possibleWidgets first). |
|
1152 |
^ self |
|
3711 | 1153 |
]. |
3716 | 1154 |
|
3700 | 1155 |
self error:'cannot select this component' |
1156 |
||
3716 | 1157 |
"Created: / 19-07-2019 / 21:59:15 / Claus Gittinger" |
1158 |
"Modified: / 20-07-2019 / 07:57:41 / Claus Gittinger" |
|
3711 | 1159 |
! |
1160 |
||
1161 |
type:aString |
|
1162 |
"enter text into the last component" |
|
1163 |
||
1164 |
<action> |
|
1165 |
||
3776 | 1166 |
|t| |
1167 |
||
3775 | 1168 |
verifying ifTrue:[^ self]. |
1169 |
||
3776 | 1170 |
t := Display ctrlDown ifTrue:[0.05] ifFalse:[0.1]. |
1171 |
lastComponent |
|
1172 |
simulateTextInput:aString at:(lastComponent extent // 2) |
|
1173 |
sendDisplayEvent:false keyPressTime:t |
|
3711 | 1174 |
|
1175 |
"Created: / 19-07-2019 / 15:50:40 / Claus Gittinger" |
|
3700 | 1176 |
! ! |
1177 |
||
1178 |
!ShowMeHowItWorks methodsFor:'defaults'! |
|
1179 |
||
1180 |
circlingCount |
|
1181 |
"circle around move-end position that many times" |
|
1182 |
||
1183 |
^ 3 |
|
1184 |
||
1185 |
"Created: / 19-07-2019 / 13:03:45 / Claus Gittinger" |
|
1186 |
! |
|
1187 |
||
1188 |
circlingRadius |
|
1189 |
"radius when circling" |
|
1190 |
||
1191 |
^ 30 "/ pixels |
|
1192 |
||
1193 |
"Created: / 19-07-2019 / 13:07:59 / Claus Gittinger" |
|
1194 |
! |
|
1195 |
||
1196 |
circlingSpeed |
|
1197 |
"time per round when circling" |
|
1198 |
||
1199 |
^ 0.3 seconds. "/ time per round |
|
1200 |
||
1201 |
"Created: / 19-07-2019 / 13:02:34 / Claus Gittinger" |
|
1202 |
! |
|
1203 |
||
1204 |
clickTime |
|
1205 |
"when clicking" |
|
1206 |
||
3711 | 1207 |
^ self shortClickTime |
3700 | 1208 |
|
1209 |
"Created: / 19-07-2019 / 13:17:20 / Claus Gittinger" |
|
3711 | 1210 |
"Modified: / 19-07-2019 / 15:21:51 / Claus Gittinger" |
1211 |
! |
|
a472042fd298
#UI_ENHANCEMENT by cg
C |