#FEATURE by exept draft
authorClaus Gittinger <cg@exept.de>
Sun, 20 Oct 2019 13:44:05 +0200
changeset 3797 5ab4b911e388
parent 3796 4ed3796c2d60
child 3798 eafc4c1bb53e
#FEATURE by exept class: ShowMeHowItWorks changed: #findComponent:in: #withViewAndPositionFor:do:
ShowMeHowItWorks.st
--- a/ShowMeHowItWorks.st	Sun Oct 20 13:15:20 2019 +0200
+++ b/ShowMeHowItWorks.st	Sun Oct 20 13:44:05 2019 +0200
@@ -1156,7 +1156,7 @@
      Uses the NameKey of the spec, and optionally the label or modelKey.
      Can return either a view or a menu item"
 
-    |idx app window component componentNameSymbol 
+    |idxString idx app window component componentNameSymbol 
      foundByName foundByHelpKey foundByTitle foundByLabel item
      checkIfAllMenuItemsDoTheSame|
 
@@ -1171,20 +1171,38 @@
             ^ self findComponent:restPath in:container
         ]
     ].
-    (componentNameOrPath matchesRegex:'item\[[0-9]+\]') ifTrue:[
+    (componentNameOrPath startsWith:'item[') ifTrue:[
         anApplicationOrViewOrMenuItem isMenu ifFalse:[
             self assert:false message:'container is not a menu'.
         ].
-        idx := Integer readFrom:(componentNameOrPath withoutPrefix:'item[') readStream.
-        item := anApplicationOrViewOrMenuItem itemAt:idx.
+        idxString := (componentNameOrPath withoutPrefix:'item[') withoutSuffix:']'.
+        (idxString conform:#isDigit) ifTrue:[
+            idx := Integer readFrom:idxString.
+            item := anApplicationOrViewOrMenuItem itemAtIndex:idx.
+        ] ifFalse:[
+            item := anApplicationOrViewOrMenuItem itemAt:idxString.
+        ].
+        self assert:item notNil.
         ^ ItemInView new view:anApplicationOrViewOrMenuItem item:item boundsInView:(item layout)
     ].
-    (componentNameOrPath matchesRegex:'tab\[[0-9]+\]') ifTrue:[
+    (componentNameOrPath startsWith:'tab[') ifTrue:[
         (anApplicationOrViewOrMenuItem isKindOf:NoteBookView) ifFalse:[
             self assert:false message:'container is not a notebook'.
         ].
-        idx := Integer readFrom:(componentNameOrPath withoutPrefix:'tab[') readStream.
-        item := anApplicationOrViewOrMenuItem tabAtIndex:idx.
+        idxString := (componentNameOrPath withoutPrefix:'tab[') withoutSuffix:']'.
+        (idxString conform:#isDigit) ifTrue:[
+            idx := Integer readFrom:idxString.
+            item := anApplicationOrViewOrMenuItem tabAtIndex:idx.
+        ] ifFalse:[
+            item := anApplicationOrViewOrMenuItem tabForWhich:[:tab | tab tabItem rawLabel = idxString].
+            item isNil ifTrue:[
+                item := anApplicationOrViewOrMenuItem tabForWhich:[:tab | tab printableLabel = idxString].
+                item isNil ifTrue:[
+                    item := anApplicationOrViewOrMenuItem tabForWhich:[:tab | tab activeHelpKey = idxString].
+                ].
+            ].
+        ].
+        self assert:item notNil.
         ^ ItemInView new view:anApplicationOrViewOrMenuItem item:item boundsInView:(item layout)
     ].
 
@@ -1456,8 +1474,9 @@
     self assert:viewOrMenuItem notNil.
     verifying ifTrue:[^ self].
 
-    (viewOrMenuItem askFor:#isMenuItem) ifTrue:[
-        viewToClick := viewOrMenuItem menuPanel.
+    ((viewOrMenuItem askFor:#isMenuItem) 
+    or:[ (viewOrMenuItem askFor:#isNoteBookTab) ]) ifTrue:[
+        viewToClick := viewOrMenuItem view.
         clickPos := viewOrMenuItem layout center.
         self assert:(clickPos notNil).
     ] ifFalse:[