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 |
|
3787
|
916 |
select:itemsIndexOrLabelOrPattern
|
3700
|
917 |
"select an item by label,
|
|
918 |
allowed after moving to:
|
3803
|
919 |
a ComboBox
|
|
920 |
a SelectionInListView
|
|
921 |
a NoteBook
|
|
922 |
a DSVColumnView
|
3700
|
923 |
"
|
|
924 |
|
|
925 |
<action>
|
|
926 |
|
3803
|
927 |
|idx component yPos tab|
|
3775
|
928 |
|
|
929 |
verifying ifTrue:[^ self].
|
|
930 |
|
3783
|
931 |
((component := lastComponent) isKindOf:ScrollableView) ifTrue:[
|
|
932 |
component := component scrolledView.
|
|
933 |
].
|
|
934 |
|
|
935 |
(component isKindOf:ComboView) ifTrue:[
|
3700
|
936 |
"/ click on the menubutton
|
3783
|
937 |
self movePointerToComponent:component menuButton.
|
|
938 |
self click:1 inComponent:component menuButton.
|
3700
|
939 |
Delay waitForSeconds:0.3.
|
3787
|
940 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[
|
|
941 |
idx := itemsIndexOrLabelOrPattern
|
|
942 |
] ifFalse:[
|
|
943 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
|
|
944 |
idx := component list findFirst:[:lbl | itemsIndexOrLabelOrPattern match:lbl]
|
|
945 |
] ifFalse:[
|
|
946 |
idx := component list indexOf:itemsIndexOrLabelOrPattern.
|
|
947 |
].
|
|
948 |
idx == 0 ifTrue:[
|
|
949 |
self error:'no such item in comboList: ',itemsIndexOrLabelOrPattern
|
|
950 |
].
|
3700
|
951 |
].
|
3783
|
952 |
component select:idx.
|
3700
|
953 |
Delay waitForSeconds:0.3.
|
3783
|
954 |
component shownMenu notNil ifTrue:[
|
|
955 |
component shownMenu hide.
|
3700
|
956 |
].
|
|
957 |
^ self
|
|
958 |
].
|
3783
|
959 |
(component isKindOf:HierarchicalListView) ifTrue:[
|
3787
|
960 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[
|
|
961 |
idx := itemsIndexOrLabelOrPattern
|
|
962 |
] ifFalse:[
|
|
963 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
|
|
964 |
idx := component indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string].
|
|
965 |
] ifFalse:[
|
|
966 |
idx := component indexOfElementForWhich:[:el | el label string = itemsIndexOrLabelOrPattern].
|
3783
|
967 |
].
|
3787
|
968 |
idx == 0 ifTrue:[
|
|
969 |
self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern
|
|
970 |
].
|
|
971 |
].
|
|
972 |
yPos := component yVisibleOfLine:idx.
|
|
973 |
self movePointerToComponent:component offset:(0 @ (yPos + 3)).
|
|
974 |
component simulateButtonPress:1 at:(0 @ (yPos + 3)) sendDisplayEvent:false.
|
|
975 |
Delay waitForSeconds:0.1.
|
|
976 |
component simulateButtonRelease:1 at:(0 @ (yPos + 3)) sendDisplayEvent:false.
|
|
977 |
"/ component selection:idx.
|
3783
|
978 |
^ self
|
|
979 |
].
|
3798
|
980 |
(component isKindOf:SelectionInListModelView) ifTrue:[
|
|
981 |
itemsIndexOrLabelOrPattern isInteger ifTrue:[
|
|
982 |
idx := itemsIndexOrLabelOrPattern
|
|
983 |
] ifFalse:[
|
|
984 |
itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
|
|
985 |
idx := component indexOfElementForWhich:[:el | el notNil and:[itemsIndexOrLabelOrPattern match:el string]].
|
|
986 |
] ifFalse:[
|
|
987 |
idx := component indexOfElementForWhich:[:el | el notNil and:[el string = itemsIndexOrLabelOrPattern]].
|
|
988 |
].
|
|
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.
|
|
999 |
^ self
|
|
1000 |
].
|
|
1001 |
|
|
1002 |
(component isKindOf:ItemInView) ifTrue:[
|
|
1003 |
component isMenuItem ifTrue:[
|
|
1004 |
self movePointerToComponent:component.
|
3803
|
1005 |
self click.
|
|
1006 |
^ self
|
3798
|
1007 |
].
|
|
1008 |
].
|
|
1009 |
|
3803
|
1010 |
(component isKindOf:NoteBookView) ifTrue:[
|
|
1011 |
(idx := itemsIndexOrLabelOrPattern) isInteger ifFalse:[
|
3814
|
1012 |
idx := component list
|
|
1013 |
findFirst:[:eachNotebookTab|
|
|
1014 |
eachNotebookTab label string = itemsIndexOrLabelOrPattern string
|
|
1015 |
or:[ eachNotebookTab printableLabel string = itemsIndexOrLabelOrPattern string ]
|
|
1016 |
].
|
|
1017 |
"/ idx := component indexOfTabNamed:itemsIndexOrLabelOrPattern
|
3803
|
1018 |
].
|
|
1019 |
tab := component tabAtIndex:idx.
|
|
1020 |
self movePointerToComponent:component offset:(tab layout center).
|
|
1021 |
component selection:idx.
|
|
1022 |
^ self
|
|
1023 |
].
|
|
1024 |
(component isKindOf:DSVColumnView) ifTrue:[
|
|
1025 |
(idx := itemsIndexOrLabelOrPattern) isInteger ifFalse:[
|
|
1026 |
self halt.
|
|
1027 |
].
|
|
1028 |
yPos := ((component yVisibleOfRowNr:idx) + (component yVisibleOfRowNr:idx+1)) // 2.
|
|
1029 |
self movePointerToComponent:component offset:(1 @ yPos).
|
|
1030 |
component selectRow:idx.
|
|
1031 |
^ self
|
|
1032 |
].
|
|
1033 |
|
|
1034 |
self error:('cannot select "%1" this component: %2' bindWith:itemsIndexOrLabelOrPattern with:component className)
|
3700
|
1035 |
|
|
1036 |
"Created: / 19-07-2019 / 12:34:25 / Claus Gittinger"
|
|
1037 |
"Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger"
|
|
1038 |
!
|
|
1039 |
|
3803
|
1040 |
selectComponent:componentName
|
|
1041 |
"Leaves component in lastComponent without moving"
|
|
1042 |
|
|
1043 |
<action>
|
|
1044 |
|
|
1045 |
|component|
|
|
1046 |
|
|
1047 |
component := self componentNamed:componentName.
|
|
1048 |
!
|
|
1049 |
|
3700
|
1050 |
selectIndex:itemsIndex
|
|
1051 |
"select an item by index,
|
|
1052 |
allowed after moving to:
|
|
1053 |
aComboBox
|
|
1054 |
aSelectionInListView
|
|
1055 |
"
|
|
1056 |
|
|
1057 |
<action>
|
|
1058 |
|
3716
|
1059 |
self selectIndex:itemsIndex in:lastComponent
|
|
1060 |
|
|
1061 |
"Created: / 19-07-2019 / 14:20:11 / Claus Gittinger"
|
|
1062 |
"Modified: / 19-07-2019 / 21:59:36 / Claus Gittinger"
|
|
1063 |
!
|
3711
|
1064 |
|
3716
|
1065 |
selectIndex:itemsIndex in:widgetArg
|
|
1066 |
"select an item by index,
|
|
1067 |
allowed after moving to:
|
|
1068 |
aComboBox
|
|
1069 |
aSelectionInListView
|
|
1070 |
"
|
|
1071 |
|
|
1072 |
<action>
|
|
1073 |
|
|
1074 |
|widget y offset possibleWidgets|
|
|
1075 |
|
3775
|
1076 |
verifying ifTrue:[^ self].
|
|
1077 |
|
3716
|
1078 |
(widget := widgetArg) isScrollWrapper ifTrue:[
|
3711
|
1079 |
widget := widget scrolledView
|
|
1080 |
].
|
|
1081 |
|
|
1082 |
(widget isKindOf:ComboView) ifTrue:[
|
3700
|
1083 |
"/ click on the menubutton
|
3711
|
1084 |
self movePointerToComponent:widget menuButton.
|
|
1085 |
self click:1 inComponent:widget menuButton.
|
3700
|
1086 |
Delay waitForSeconds:0.5.
|
3711
|
1087 |
widget select:itemsIndex.
|
3700
|
1088 |
Delay waitForSeconds:0.5.
|
|
1089 |
^ self
|
|
1090 |
].
|
3711
|
1091 |
(widget isKindOf:SelectionInListView) ifTrue:[
|
3716
|
1092 |
(widget isLineVisible:itemsIndex) ifFalse:[
|
|
1093 |
widget scrollToLine:itemsIndex
|
|
1094 |
].
|
3711
|
1095 |
"/ click on the item
|
|
1096 |
y := widget yOfLine:itemsIndex.
|
|
1097 |
offset := (widget width // 2) @ y.
|
|
1098 |
self movePointerToComponent:widget offset:offset.
|
|
1099 |
widget simulateButtonPress:1 at:offset sendDisplayEvent:false.
|
|
1100 |
Delay waitForSeconds:(self clickTime).
|
|
1101 |
widget simulateButtonRelease:1 at:offset sendDisplayEvent:false.
|
|
1102 |
Delay waitForSeconds:0.5.
|
|
1103 |
^ self
|
3716
|
1104 |
].
|
|
1105 |
(widget isKindOf:SelectionInListModelView) ifTrue:[
|
|
1106 |
(widget isLineVisible:itemsIndex) ifFalse:[
|
|
1107 |
widget scrollToLine:itemsIndex
|
|
1108 |
].
|
|
1109 |
y := widget yVisibleOfLine:itemsIndex.
|
|
1110 |
offset := (widget width // 2) @ y.
|
|
1111 |
self movePointerToComponent:widget offset:offset.
|
|
1112 |
widget simulateButtonPress:1 at:offset sendDisplayEvent:false.
|
|
1113 |
Delay waitForSeconds:(self clickTime).
|
|
1114 |
widget simulateButtonRelease:1 at:offset sendDisplayEvent:false.
|
|
1115 |
Delay waitForSeconds:0.5.
|
|
1116 |
^ self
|
|
1117 |
].
|
|
1118 |
|
|
1119 |
"/ none of it - see what is in there
|
|
1120 |
possibleWidgets := OrderedCollection new.
|
|
1121 |
widget allSubViewsDo:[:each |
|
|
1122 |
((each isKindOf:ComboView)
|
|
1123 |
or:[(each isKindOf:SelectionInListView)
|
|
1124 |
or:[(each isKindOf:SelectionInListModelView)
|
|
1125 |
]]) ifTrue:[
|
|
1126 |
possibleWidgets add:each
|
|
1127 |
]
|
|
1128 |
].
|
|
1129 |
possibleWidgets size == 1 ifTrue:[
|
|
1130 |
self selectIndex:itemsIndex in:(possibleWidgets first).
|
|
1131 |
^ self
|
3711
|
1132 |
].
|
3716
|
1133 |
|
3700
|
1134 |
self error:'cannot select this component'
|
|
1135 |
|
3716
|
1136 |
"Created: / 19-07-2019 / 21:59:15 / Claus Gittinger"
|
|
1137 |
"Modified: / 20-07-2019 / 07:57:41 / Claus Gittinger"
|
3711
|
1138 |
!
|
|
1139 |
|
|
1140 |
type:aString
|
|
1141 |
"enter text into the last component"
|
|
1142 |
|
|
1143 |
<action>
|
|
1144 |
|
3776
|
1145 |
|t|
|
|
1146 |
|
3775
|
1147 |
verifying ifTrue:[^ self].
|
|
1148 |
|
3776
|
1149 |
t := Display ctrlDown ifTrue:[0.05] ifFalse:[0.1].
|
|
1150 |
lastComponent
|
|
1151 |
simulateTextInput:aString at:(lastComponent extent // 2)
|
|
1152 |
sendDisplayEvent:false keyPressTime:t
|
3711
|
1153 |
|
|
1154 |
"Created: / 19-07-2019 / 15:50:40 / Claus Gittinger"
|
3700
|
1155 |
! !
|
|
1156 |
|
|
1157 |
!ShowMeHowItWorks methodsFor:'defaults'!
|
|
1158 |
|
|
1159 |
circlingCount
|
|
1160 |
"circle around move-end position that many times"
|
|
1161 |
|
|
1162 |
^ 3
|
|
1163 |
|
|
1164 |
"Created: / 19-07-2019 / 13:03:45 / Claus Gittinger"
|
|
1165 |
!
|
|
1166 |
|
|
1167 |
circlingRadius
|
|
1168 |
"radius when circling"
|
|
1169 |
|
|
1170 |
^ 30 "/ pixels
|
|
1171 |
|
|
1172 |
"Created: / 19-07-2019 / 13:07:59 / Claus Gittinger"
|
|
1173 |
!
|
|
1174 |
|
|
1175 |
circlingSpeed
|
|
1176 |
"time per round when circling"
|
|
1177 |
|
|
1178 |
^ 0.3 seconds. "/ time per round
|
|
1179 |
|
|
1180 |
"Created: / 19-07-2019 / 13:02:34 / Claus Gittinger"
|
|
1181 |
!
|
|
1182 |
|
|
1183 |
clickTime
|
|
1184 |
"when clicking"
|
|
1185 |
|
3711
|
1186 |
^ self shortClickTime
|
3700
|
1187 |
|
|
1188 |
"Created: / 19-07-2019 / 13:17:20 / Claus Gittinger"
|
3711
|
1189 |
"Modified: / 19-07-2019 / 15:21:51 / Claus Gittinger"
|
|
1190 |
!
|
|
1191 |
|
|
1192 |
longClickTime
|
|
1193 |
"when clicking buttons"
|
|
1194 |
|
|
1195 |
^ 500 milliseconds
|
|
1196 |
|
|
1197 |
"Created: / 19-07-2019 / 15:21:42 / Claus Gittinger"
|
3700
|
1198 |
!
|
|
1199 |
|
|
1200 |
pointerAnimationDelay
|
|
1201 |
^ 50 milliseconds. "/ 20 updates per second
|
|
1202 |
|
|
1203 |
"Created: / 19-07-2019 / 13:04:45 / Claus Gittinger"
|
|
1204 |
!
|
|
1205 |
|
|
1206 |
pointerMoveSpeed
|
|
1207 |
^ 400. "/ pixels per second
|
|
1208 |
|
|
1209 |
"Created: / 19-07-2019 / 13:05:40 / Claus Gittinger"
|
|
1210 |
!
|
|
1211 |
|
3717
|
1212 |
pointerMoveSpeedFast
|
|
1213 |