#FEATURE by exept
authorClaus Gittinger <cg@exept.de>
Sat, 02 Nov 2019 01:25:51 +0100
changeset 3814 b57cff575911
parent 3813 04c48e162a22
child 3815 d9b849d3e63f
#FEATURE by exept class: ShowMeHowItWorks changed: #findComponent:in: #select:
ShowMeHowItWorks.st
--- a/ShowMeHowItWorks.st	Fri Nov 01 05:52:58 2019 +0100
+++ b/ShowMeHowItWorks.st	Sat Nov 02 01:25:51 2019 +0100
@@ -1006,7 +1006,12 @@
 
     (component isKindOf:NoteBookView) ifTrue:[
         (idx := itemsIndexOrLabelOrPattern) isInteger ifFalse:[
-            idx := component indexOfTabNamed:itemsIndexOrLabelOrPattern
+            idx := component list
+                    findFirst:[:eachNotebookTab| 
+                        eachNotebookTab label string = itemsIndexOrLabelOrPattern string
+                        or:[ eachNotebookTab printableLabel string = itemsIndexOrLabelOrPattern string ]
+                    ].
+            "/ idx := component indexOfTabNamed:itemsIndexOrLabelOrPattern
         ].
         tab := component tabAtIndex:idx.
         self movePointerToComponent:component offset:(tab layout center).
@@ -1454,33 +1459,54 @@
     ].
 
     (componentNameOrPath startsWith:'item[') ifTrue:[
-        anApplicationOrViewOrMenuItem isMenu ifFalse:[
-            self assert:false message:'container is not a menu'.
-        ].
         idxString := (componentNameOrPath withoutPrefix:'item[') withoutSuffix:']'.
         (idxString conform:#isDigit) ifTrue:[
             idx := Integer readFrom:idxString.
-            item := anApplicationOrViewOrMenuItem itemAtIndex:idx.
         ] ifFalse:[
             idxString := idxString withoutQuotes.
-            idxString includesMatchCharacters ifTrue:[
-                item := 
-                    anApplicationOrViewOrMenuItem itemForWhich:[:item |
-                        (idxString match:(item nameKey ? '') )
-                        or:[ (idxString match:(item textLabel ? '')) 
-                        or:[ (item value isSymbol and:[idxString match:(item value)])]]
-                    ]  
+            idx := nil.
+        ].
+
+        (anApplicationOrViewOrMenuItem isKindOf:NoteBookView) ifTrue:[
+            idx isNil ifTrue:[
+                idxString includesMatchCharacters ifTrue:[
+                    idx := anApplicationOrViewOrMenuItem list 
+                                findFirst:[:aTab| (aTab label matches:idxString)
+                                                    or:[aTab printableLabel matches:idxString]].
+                ] ifFalse:[
+                    idx := anApplicationOrViewOrMenuItem listIndexOf:idxString
+                ].
+            ].
+            idx notNil ifTrue:[
+                self halt.
+            ]
+        ] ifFalse:[
+            anApplicationOrViewOrMenuItem isMenu ifFalse:[
+                self assert:false message:'container is not a menu'.
+            ].
+            "/ a menu item
+            idx notNil ifTrue:[
+                item := anApplicationOrViewOrMenuItem itemAtIndex:idx.
             ] ifFalse:[
-                item := 
-                    anApplicationOrViewOrMenuItem itemForWhich:[:item |
-                        item nameKey = idxString
-                        or:[ item textLabel = idxString 
-                        or:[ (item value isSymbol and:[ item value = idxString ])]]
-                    ]
+                idxString includesMatchCharacters ifTrue:[
+                    item := 
+                        anApplicationOrViewOrMenuItem itemForWhich:[:item |
+                            (idxString match:(item nameKey ? '') )
+                            or:[ (idxString match:(item textLabel ? '')) 
+                            or:[ (item value isSymbol and:[idxString match:(item value)])]]
+                        ]  
+                ] ifFalse:[
+                    item := 
+                        anApplicationOrViewOrMenuItem itemForWhich:[:item |
+                            item nameKey = idxString
+                            or:[ item textLabel = idxString 
+                            or:[ (item value isSymbol and:[ item value = idxString ])]]
+                        ]
+                ].
             ].
+            self assert:item notNil message:('no menu item named "%1"' bindWith:idxString).
+            ^ ItemInView new view:anApplicationOrViewOrMenuItem item:item boundsInView:(item layout)
         ].
-        self assert:item notNil message:('no menu item named "%1"' bindWith:idxString).
-        ^ ItemInView new view:anApplicationOrViewOrMenuItem item:item boundsInView:(item layout)
     ].
     (componentNameOrPath startsWith:'tab[') ifTrue:[
         (anApplicationOrViewOrMenuItem isKindOf:NoteBookView) ifFalse:[