#FEATURE by exept draft
authorClaus Gittinger <cg@exept.de>
Wed, 02 Oct 2019 02:20:29 +0200
changeset 3776 371ad059085a
parent 3775 0e44d27ee647
child 3777 bc17ad12cef0
#FEATURE by exept class: ShowMeHowItWorks added: #raise: #show:saying: #show:saying:for: #showing:saying:do: changed: #do: #findComponent: #moveTo: #show: #showing:do: #type: #wait:
ShowMeHowItWorks.st
--- a/ShowMeHowItWorks.st	Tue Oct 01 20:03:56 2019 +0200
+++ b/ShowMeHowItWorks.st	Wed Oct 02 02:20:29 2019 +0200
@@ -143,12 +143,32 @@
     "Modified: / 19-07-2019 / 16:13:33 / Claus Gittinger"
 !
 
+raise:what
+    <action>
+
+    verifying ifTrue:[^ self].
+
+    what == #application ifTrue:[
+        application topView raise.
+        ^ self
+    ].
+    what == #masterApplication ifTrue:[
+        application windowGroup isModal ifTrue:[
+            application windowGroup mainGroup topViews first raise
+        ] ifFalse:[
+            (application masterApplication ? application) topViews first raise.
+        ].
+        ^ self
+    ].
+    self halt.
+!
+
 show:message
     "showing (and speak) some message."
 
     <action>
     
-    self showing:message do:nil
+    self showing:message saying:nil do:nil
 
     "Created: / 19-07-2019 / 15:59:18 / Claus Gittinger"
     "Modified (comment): / 19-07-2019 / 18:54:36 / Claus Gittinger"
@@ -165,11 +185,41 @@
     "Created: / 19-07-2019 / 18:54:20 / Claus Gittinger"
 !
 
+show:message saying:sentenceOrNil
+    "showing (and speak) some message."
+
+    <action>
+    
+    self showing:message saying:sentenceOrNil do:nil
+
+    "Created: / 19-07-2019 / 15:59:18 / Claus Gittinger"
+    "Modified (comment): / 19-07-2019 / 18:54:36 / Claus Gittinger"
+!
+
+show:message saying:sentenceOrNil for:seconds
+    "showing (and speak) some message and wait for some time."
+
+    <action>
+    
+    self show:message saying:sentenceOrNil.
+    self wait:seconds.
+
+    "Created: / 19-07-2019 / 18:54:20 / Claus Gittinger"
+!
+
 showing:message do:operationsOrNothing
     "execute operationsOrNothing while showing (and speaking) some message."
 
     <action>
     
+    self showing:message saying:nil do:operationsOrNothing
+!
+
+showing:message saying:sentenceOrNil do:operationsOrNothing
+    "execute operationsOrNothing while showing (and speaking) some message."
+
+    <action>
+    
     |xLatedMessage messageView talkDone|
 
     xLatedMessage := (translate and:[application notNil]) 
@@ -187,7 +237,7 @@
         self talking ifTrue:[
             talkDone := Semaphore new.
             [
-                self tell:xLatedMessage.
+                self tell:(sentenceOrNil ? xLatedMessage).
                 talkDone signal
             ] fork.
             
@@ -224,6 +274,8 @@
     <action>
     
     verifying ifTrue:[^ self].
+    Display ctrlDown ifTrue:[^ self].
+
     Delay waitForSeconds:seconds
 
     "Created: / 19-07-2019 / 15:09:45 / Claus Gittinger"
@@ -325,6 +377,7 @@
 
     component := self componentNamed:componentName.
     self movePointerToComponent:component.
+    Display ctrlDown ifTrue:[^ self].
     self circlePointerAroundComponent:component.
 
     "Created: / 19-07-2019 / 11:20:42 / Claus Gittinger"
@@ -461,9 +514,14 @@
 
     <action>
 
+    |t|
+
     verifying ifTrue:[^ self].
 
-    lastComponent simulateTextInput:aString at:(lastComponent extent // 2) sendDisplayEvent:false
+    t := Display ctrlDown ifTrue:[0.05] ifFalse:[0.1].
+    lastComponent 
+        simulateTextInput:aString at:(lastComponent extent // 2) 
+        sendDisplayEvent:false keyPressTime:t
 
     "Created: / 19-07-2019 / 15:50:40 / Claus Gittinger"
 ! !
@@ -638,15 +696,28 @@
     "find a component by name - in the active and possibly in any app.
      Can return either a view or a menu item"
     
-    |component candidates|
+    |component candidates modalGroup|
 
     application notNil ifTrue:[ 
         component := self findComponent:componentName in:application.
     ].
-    
     component isNil ifTrue:[
+        candidates := OrderedCollection new.
+
+        "/ is there a modal dialog open for the app?
+        (modalGroup := application windowGroup modalGroup) notNil ifTrue:[
+            modalGroup topViews do:[:eachModalTopView |
+                component := self findComponent:componentName in:eachModalTopView.
+                component notNil ifTrue:[ 
+                    candidates add:component
+                ].
+            ].
+            candidates size == 1 ifTrue:[
+                ^ candidates first
+            ].
+        ].
+
         "/ search through all current applications
-        candidates := OrderedCollection new.
         WindowGroup scheduledWindowGroups do:[:eachWG |
             |eachApp|
 
@@ -1027,8 +1098,8 @@
     verifying := true.
     [
         Error handle:[:ex |
-            (Dialog confirm:(self class classResources stringWithCRs:'Error encountered while verifying:\\%1\\Debug?' with:ex description))
-            ifTrue:[ex reject].
+            Transcript showCR:'Possible error (encountered while verifying):\\%1\\Debug?' with:ex description.
+            Display ctrlDown ifTrue:[ex reject].
         ] do:[
             self doStream:(specArray readStream)
         ].