--- a/ShowMeHowItWorks.st Fri Oct 18 23:29:24 2019 +0200
+++ b/ShowMeHowItWorks.st Sun Oct 20 08:13:53 2019 +0200
@@ -1014,7 +1014,8 @@
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 foundByName foundByTitle foundByLabel item
+ |idx app window component componentNameSymbol
+ foundByName foundByHelpKey foundByTitle foundByLabel item
checkIfAllMenuItemsDoTheSame|
(componentNameOrPath includes:$/) ifTrue:[
@@ -1052,6 +1053,7 @@
"/ or it has changed its name.
"/ look for: widget's name, widget's title, widget's label
foundByName := OrderedCollection new.
+ foundByHelpKey := OrderedCollection new.
foundByTitle := OrderedCollection new.
foundByLabel := OrderedCollection new.
@@ -1060,35 +1062,36 @@
foundIt := false.
each shown ifTrue:[
- [
- each name = componentNameSymbol ifTrue:[ foundByName add:each. foundIt := true ].
- ] on:MessageNotUnderstood do:[:ex | ].
- foundIt ifFalse:[
- [
- each title = componentNameSymbol ifTrue:[ foundByTitle add:each. foundIt := true ].
- ] on:MessageNotUnderstood do:[:ex | ].
+ {
+ #name . foundByName .
+ #helpKey . foundByHelpKey .
+ #title . foundByTitle .
+ #label . foundByLabel .
+ } pairWiseDo:[:attr :coll |
foundIt ifFalse:[
[
- each label = componentNameSymbol ifTrue:[ foundByLabel add:each. foundIt := true ].
+ (each perform:attr) = componentNameSymbol ifTrue:[
+ coll add:each. foundIt := true
+ ]
] on:MessageNotUnderstood do:[:ex | ].
+ ]
+ ].
+ foundIt ifFalse:[
+ each isMenu ifTrue:[
+ (item := each detectItemForNameKey:componentNameSymbol) notNil ifTrue:[
+ foundByName add:item. foundIt := true
+ ].
foundIt ifFalse:[
- each isMenu ifTrue:[
- (item := each detectItemForNameKey:componentNameSymbol) notNil ifTrue:[
- foundByName add:item. foundIt := true
- ].
- foundIt ifFalse:[
- (item := each detectItemForKey:componentNameSymbol) notNil ifTrue:[
- foundByName add:item. foundIt := true
- ].
- foundIt ifFalse:[
- (item := each detectItemForLabel:componentNameSymbol) notNil ifTrue:[
- foundByLabel add:item. foundIt := true
- ].
- ].
- ].
+ (item := each detectItemForKey:componentNameSymbol) notNil ifTrue:[
+ foundByName add:item. foundIt := true
].
+ foundIt ifFalse:[
+ (item := each detectItemForLabel:componentNameSymbol) notNil ifTrue:[
+ foundByLabel add:item. foundIt := true
+ ].
+ ].
].
- ]
+ ].
].
].
].
@@ -1115,6 +1118,11 @@
self assert:(foundByName size == 1) message:'multiple components found by name'.
^ foundByName first.
].
+ foundByHelpKey notEmpty ifTrue:[
+ checkIfAllMenuItemsDoTheSame value:foundByHelpKey.
+ self assert:(foundByHelpKey size == 1) message:'multiple components found by helpKey'.
+ ^ foundByHelpKey first.
+ ].
foundByTitle notEmpty ifTrue:[
checkIfAllMenuItemsDoTheSame value:foundByTitle.
self assert:(foundByTitle size == 1) message:'multiple components found by title'.