#FEATURE by exept
class: ShowMeHowItWorks
added: #initialize
changed:
#click:inComponent:clickTime:
#freezePin:ofStep:with:
#pushApplication:
#select:
#selectPin:ofStep:
class: ShowMeHowItWorks class
added: #new
--- a/ShowMeHowItWorks.st Wed Feb 19 22:42:34 2020 +0100
+++ b/ShowMeHowItWorks.st Thu Feb 20 09:46:13 2020 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 2018 by eXept Software AG
All Rights Reserved
@@ -152,6 +154,14 @@
"
! !
+!ShowMeHowItWorks class methodsFor:'instance creation'!
+
+new
+ "return an initialized instance"
+
+ ^ self basicNew initialize.
+! !
+
!ShowMeHowItWorks class methodsFor:'running'!
application:anApplicationOrNilForAll do:specArray
@@ -165,7 +175,7 @@
ShowMeHowItWorks do:
#(
(language: de)
- (show: 'üben üben üben')
+ (show: 'üben üben üben')
(wait: 0.5)
(moveTo: NameOfComponent)
)
@@ -186,7 +196,7 @@
ShowMeHowItWorks do:
#(
(language: de)
- (show: 'üben üben üben')
+ (show: 'üben üben üben')
(wait: 0.5)
(moveTo: NameOfComponent)
)
@@ -205,7 +215,7 @@
ShowMeHowItWorks do:
#(
(language: de)
- (show: 'üben üben üben')
+ (show: 'üben üben üben')
(wait: 0.5)
(moveTo: NameOfComponent)
)
@@ -227,7 +237,7 @@
ShowMeHowItWorks
do:#(
(language: de)
- (show: 'üben üben üben')
+ (show: 'üben üben üben')
(wait: 0.5)
(moveTo: NameOfComponent)
)
@@ -247,7 +257,7 @@
ShowMeHowItWorks
do:#(
(language: de)
- (show: 'üben üben üben')
+ (show: 'üben üben üben')
(wait: 0.5)
(moveTo: NameOfComponent)
)
@@ -290,6 +300,10 @@
diagramEditor := lastComponent scrolledView
].
pinPO := self pinPOForPin:pinName ofStep:stepName.
+ pinPO isNil ifTrue:[
+ self error:('No pin named "%1" for step "%2" found in diagram' bindWith:pinName with:stepName).
+ ^ self.
+ ].
diagramEditor selection:{ pinPO }.
diagramEditor doubleClickOn:pinPO.
@@ -388,7 +402,10 @@
(newApplication := newApplicationOrName) isString ifTrue:[
newApplication := self findApplication:newApplicationOrName ifMultiple:nil.
- self assert: newApplication notNil.
+ newApplication isNil ifTrue:[
+ self error:('Could not find an application named "%1" (to switch to)' bindWith:newApplicationOrName).
+ ].
+ "/ self assert: newApplication notNil.
].
applicationStack isNil ifTrue:[applicationStack := OrderedCollection new].
@@ -431,7 +448,10 @@
Delay waitForSeconds:0.1.
pinPO := self pinPOForPin:pinName ofStep:stepName.
] doWhile:[pinPO isNil and:[ (count := count+1) < 20]].
-
+ pinPO isNil ifTrue:[
+ self error:('No pin named "%1" for step "%2" found in diagram' bindWith:pinName with:stepName).
+ ^ self.
+ ].
self movePointerToComponent:diagramEditor offset:(pinPO frame center).
diagramEditor selection:{ pinPO }.
!
@@ -1112,11 +1132,16 @@
(component isKindOf:NoteBookView) ifTrue:[
(idx := itemsIndexOrLabelOrPattern) isInteger ifFalse:[
- idx := component list
+ idx := component tabList
findFirst:[:eachNotebookTab|
- eachNotebookTab label string = itemsIndexOrLabelOrPattern string
- or:[ eachNotebookTab printableLabel string = itemsIndexOrLabelOrPattern string ]
- ].
+ eachNotebookTab labelString string = itemsIndexOrLabelOrPattern string
+ or:[ (eachNotebookTab printableLabel string = itemsIndexOrLabelOrPattern string)
+ or:[ eachNotebookTab label isString not
+ and:[eachNotebookTab label label = itemsIndexOrLabelOrPattern string ]]]
+ ].
+ idx == 0 ifTrue:[
+ self error:('No tab named "%1" found' with:itemsIndexOrLabelOrPattern string)
+ ].
"/ idx := component indexOfTabNamed:itemsIndexOrLabelOrPattern
].
tab := component tabAtIndex:idx.
@@ -1911,27 +1936,35 @@
"press-release in a component"
self withViewAndPositionFor:viewOrMenuItem do:[:viewToClick :clickPos |
+ |clickDone|
+
+ clickDone := false.
Display activePointerGrab == Display rootView ifTrue:[
|pos|
pos := Display translatePoint:clickPos fromView:viewToClick toView:nil.
- OperatingSystem isOSXlike ifTrue:[
- OperatingSystem
- generateMouseMoveEventX:pos x y:pos y;
- generateButtonEvent:buttonNr down:true x:pos x y:pos y;
- yourself.
+ Error handle:[:ex |
+ ] do:[
+ OperatingSystem isOSXlike ifTrue:[
+ OperatingSystem
+ generateMouseMoveEventX:pos x y:pos y;
+ generateButtonEvent:buttonNr down:true x:pos x y:pos y;
+ yourself.
+ Delay waitForSeconds:clickTime.
+ OperatingSystem
+ generateButtonEvent:buttonNr down:false x:pos x y:pos y;
+ "/ generateButtonEvent:buttonNr down:true x:pos x y:pos y;
+ "/ generateButtonEvent:buttonNr down:false x:pos x y:pos y;
+ yourself.
+ ^ self.
+ ].
+ Display rootView simulateButtonPress:buttonNr at:pos sendDisplayEvent:true.
Delay waitForSeconds:clickTime.
- OperatingSystem
- generateButtonEvent:buttonNr down:false x:pos x y:pos y;
- "/ generateButtonEvent:buttonNr down:true x:pos x y:pos y;
- "/ generateButtonEvent:buttonNr down:false x:pos x y:pos y;
- yourself.
- ^ self.
+ Display rootView simulateButtonRelease:buttonNr at:pos sendDisplayEvent:true.
+ clickDone := true.
].
- Display rootView simulateButtonPress:buttonNr at:pos sendDisplayEvent:true.
- Delay waitForSeconds:clickTime.
- Display rootView simulateButtonRelease:buttonNr at:pos sendDisplayEvent:true.
- ] ifFalse:[
+ ].
+ clickDone ifFalse:[
viewToClick simulateButtonPress:buttonNr at:clickPos sendDisplayEvent:false.
Delay waitForSeconds:clickTime.
viewToClick simulateButtonRelease:buttonNr at:clickPos sendDisplayEvent:false.
@@ -2187,6 +2220,33 @@
self error:'where is this'
! !
+!ShowMeHowItWorks methodsFor:'initialization'!
+
+initialize
+ "Invoked when a new instance is created."
+
+ "/ please change as required (and remove this comment)
+ "/ application := nil.
+ "/ opStream := nil.
+ "/ streamStack := nil.
+ "/ lastComponentName := nil.
+ "/ lastComponent := nil.
+ "/ lastResult := nil.
+ "/ voice := nil.
+ "/ translate := nil.
+ "/ language := nil.
+ verifying := false.
+ "/ closeApplicationWhenFinished := nil.
+ "/ defaultComponentWaitTime := nil.
+ "/ ui := nil.
+ "/ theShowFile := nil.
+ "/ defaultElementTimeout := nil.
+ "/ applicationStack := nil.
+ "/ pronunciations := nil.
+
+ "/ super initialize. -- commented since inherited method does nothing
+! !
+
!ShowMeHowItWorks methodsFor:'running'!
do:specArray