#UI_ENHANCEMENT by cg
authorClaus Gittinger <cg@exept.de>
Fri, 13 May 2016 02:54:14 +0200
changeset 5736 38cdf9557610
parent 5735 5fbcb3739f7c
child 5740 430b7b15a684
child 5741 f18b564ed955
#UI_ENHANCEMENT by cg class: TextView changed: #openSearchBoxAndSearch modeless behavior
TextView.st
--- a/TextView.st	Thu May 12 21:28:42 2016 +0200
+++ b/TextView.st	Fri May 13 02:54:14 2016 +0200
@@ -2218,8 +2218,10 @@
 !
 
 openSearchBoxAndSearch
-    "search for a string - show a box to enter searchpattern
-     - currently no regular expressions are handled."
+    "search for a string - show a box to enter searchpattern.
+     TODO: this started as an ad-hoc box, which is manually constructed.
+     over time, it got more and more functions, so a separate appModel class
+     would no be appropriate..."
 
     "
      Q: is it a good idea to preserve the last searchstring between views?
@@ -2383,20 +2385,24 @@
     bindings := IdentityDictionary new.
     bindings at:#searchPattern put:patternHolder.
     modal ifTrue:[
-        bindings at:#nextAction put:[
-            replaceAllBooleanHolder value ifTrue:[
-                searchBox doAccept.
-            ] ifFalse:[
-                doSearch value:true
-            ]    
-        ].
-        bindings at:#prevAction put:[
-            replaceAllBooleanHolder value ifTrue:[
-                fwd := false. searchBox doAccept.
-            ] ifFalse:[
-                doSearch value:false
-            ]    
-        ].
+        bindings 
+            at:#nextAction 
+            put:[
+                replaceAllBooleanHolder value ifTrue:[
+                    searchBox doAccept.
+                ] ifFalse:[
+                    doSearch value:true
+                ]    
+            ].
+        bindings
+            at:#prevAction 
+            put:[
+                replaceAllBooleanHolder value ifTrue:[
+                    fwd := false. searchBox doAccept.
+                ] ifFalse:[
+                    doSearch value:false
+                ]    
+            ].
     ] ifFalse:[
         bindings at:#nextAction put:[doSearch value:true.].
         bindings at:#prevAction put:[doSearch value:false.].
@@ -2503,6 +2509,9 @@
                 openInGroup:(self windowGroup);
                 waitUntilVisible;
                 assignKeyboardFocusToFirstKeyboardConsumer.
+        searchBox window keyboardProcessor        
+            addAccelerator:#Return action:(bindings at:#nextAction);
+            addAccelerator:#Escape action:#closeRequest.
         "/ remember this box for me.
         self objectAttributeAt:#currentModelessSearchBox put:searchBox.
     ]