2009-12-01 Joseph Pecoraro <joepeck@webkit.org>
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Dec 2009 20:08:18 +0000 (20:08 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Dec 2009 20:08:18 +0000 (20:08 +0000)
        Reviewed by Timothy Hatcher.

        Web Inspector: Escape key in the Search Field should be more User Friendly
        https://bugs.webkit.org/show_bug.cgi?id=32005

        * inspector/front-end/inspector.js:
        (WebInspector.loaded): add mousedown listener on the search field
        (WebInspector.searchFieldManualFocus): user clicked to focus on the search field
        (WebInspector.searchKeyDown): handle escape

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@51553 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/inspector/front-end/inspector.js

index be6ac77..d252747 100644 (file)
@@ -1,3 +1,15 @@
+2009-12-01  Joseph Pecoraro  <joepeck@webkit.org>
+
+        Reviewed by Timothy Hatcher.
+
+        Web Inspector: Escape key in the Search Field should be more User Friendly
+        https://bugs.webkit.org/show_bug.cgi?id=32005
+
+        * inspector/front-end/inspector.js:
+        (WebInspector.loaded): add mousedown listener on the search field
+        (WebInspector.searchFieldManualFocus): user clicked to focus on the search field
+        (WebInspector.searchKeyDown): handle escape
+
 2009-12-01  Dave Hyatt  <hyatt@apple.com>
 
         Reviewed by David Kilzer.
index ce234f8..7d5adaf 100644 (file)
@@ -503,6 +503,7 @@ WebInspector.loaded = function()
 
     var searchField = document.getElementById("search");
     searchField.addEventListener("search", this.performSearch.bind(this), false); // when the search is emptied
+    searchField.addEventListener("mousedown", this.searchFieldManualFocus.bind(this), false); // when the search field is manually selected
 
     toolbarElement.addEventListener("mousedown", this.toolbarDragStart, true);
     document.getElementById("close-button-left").addEventListener("click", this.close, true);
@@ -1529,8 +1530,28 @@ WebInspector.addMainEventListeners = function(doc)
     doc.addEventListener("click", this.documentClick.bind(this), true);
 }
 
+WebInspector.searchFieldManualFocus = function(event)
+{
+    this.currentFocusElement = event.target;
+    this._previousFocusElement = event.target;
+}
+
 WebInspector.searchKeyDown = function(event)
 {
+    // Escape Key will clear the field and clear the search results
+    if (event.keyCode === WebInspector.KeyboardShortcut.KeyCodes.Esc) {
+        event.preventDefault();
+        event.handled = true;
+        event.target.value = "";
+
+        this.performSearch(event);
+        this.currentFocusElement = this.previousFocusElement;
+        if (this.currentFocusElement === event.target)
+            this.currentFocusElement.select();
+
+        return false;
+    }
+
     if (!isEnterKey(event))
         return false;