SettingsDialog.st
changeset 16318 c63c5afa0cc9
parent 16313 6abedc9963c0
child 16321 e6a4ab0da993
child 16325 073884e3213d
--- a/SettingsDialog.st	Sun Apr 24 15:13:35 2016 +0200
+++ b/SettingsDialog.st	Sun Apr 24 15:13:50 2016 +0200
@@ -1826,17 +1826,44 @@
     widgetsToHighlight := Set new.
     words := app quickSearchStrings.
     
-    (words contains:[:word | pattern match:word]) ifTrue:[
-        "/ ok - there is a match
-        app window withAllSubViewsDo:[:v |
-            v helpKey notNil ifTrue:[
-                (pattern match:v helpKey caseSensitive:false) ifTrue:[
-                    |alreadyIn|
-                    
-                    alreadyIn := false.
-                    v allSuperViewsDo:[:sv | (widgetsToHighlight includes:sv) ifTrue:[ alreadyIn := true]].
-                    alreadyIn ifFalse:[ widgetsToHighlight add:v ].
-                ].   
+    (words contains:[:word | pattern match:word caseSensitive:false]) ifTrue:[
+        "/ ok - there is a match in this app;
+        "/ look which widget matches it in its helpKey or label
+        
+        app window withAllSubViewsDo:[:eachView |
+            |wordsInWidget widgetHasIt label helpKey xLatedText helpText|
+
+            wordsInWidget := Set new.
+             
+            (helpKey := eachView helpKey) notNil ifTrue:[
+                wordsInWidget add:helpKey.
+                helpText := app helpTextForKey:helpKey.
+                helpText notNil ifTrue:[
+                    helpText asCollectionOfWordsDo:[:w | wordsInWidget add:w asLowercase].
+                    xLatedText := app resources string:helpText.
+                    (xLatedText notNil and:[xLatedText ~= helpText]) ifTrue:[
+                        xLatedText asCollectionOfWordsDo:[:w | wordsInWidget add:w asLowercase].
+                    ].    
+                ].    
+            ].
+            label := eachView perform:#label ifNotUnderstood:nil.
+            (label notNil and:[label isString]) ifTrue:[
+                label := label string.
+                label asCollectionOfWordsDo:[:w | wordsInWidget add:w asLowercase].
+                xLatedText := app resources string:label.
+                (xLatedText notNil and:[xLatedText ~= label]) ifTrue:[
+                    xLatedText asCollectionOfWordsDo:[:w | wordsInWidget add:w asLowercase].
+                ].    
+            ].
+            
+            widgetHasIt := wordsInWidget contains:[:w | pattern match:w caseSensitive:false ].
+            widgetHasIt ifTrue:[
+                |alreadyIn|
+                
+                "/ check if a superview also has it (frames/framedboxes, etc.)
+                alreadyIn := false.
+                eachView allSuperViewsDo:[:sv | (widgetsToHighlight includes:sv) ifTrue:[ alreadyIn := true]].
+                alreadyIn ifFalse:[ widgetsToHighlight add:eachView ].
             ].   
         ].   
     ].
@@ -1846,6 +1873,8 @@
 quickSearchStringHolderChanged
     |oldSelection searchString pattern matches|
     
+    self unhighlightWidgets.
+
     oldSelection := self selectedItem value.
     
     "/ make all labels normal
@@ -1854,7 +1883,10 @@
     ]. 
 
     searchString := self quickSearchStringHolder value.
-    searchString isEmptyOrNil ifTrue:[^ self].
+    searchString isEmptyOrNil ifTrue:[
+        ^ self
+    ].
+    
     pattern := '*',searchString,'*'.
 
     applicationList root recursiveExpand.
@@ -1886,24 +1918,13 @@
     oldSelection notNil ifTrue:[
         oldSelection makeVisible.
         self selectedItem value:oldSelection.
+        self highlightWidgetsWithMatchingSearchString.
     ].    
 !
 
-unhighlightWidget:aWidget
-    "unhighlight a matching widget"
-
-    highlightedWidgetsOriginalAttributes notNil ifTrue:[
-        highlightedWidgetsOriginalAttributes keysAndValuesDo:[:widget :oldValues |
-            oldValues keysAndValuesDo:[:sel :oldValue |
-                widget perform:sel with:oldValue
-            ].    
-        ].    
-        highlightedWidgetsOriginalAttributes := nil.
-    ].  
-!
-
 unhighlightWidgets
-    "unhighlight a matching widget"
+    "unhighlight all previously highligted widgets
+     (restore their previous attributes)"
 
     highlightedWidgetsOriginalAttributes notNil ifTrue:[
         highlightedWidgetsOriginalAttributes keysAndValuesDo:[:widget :oldValues |