Bug 49474 - Filter editor UI: make Enter key add a new criteria line instead of OK-ing the dialog. ui-r=bwinton, r=mconley, r=IanN
authoraceman <acelists@atlas.sk>
Thu, 13 Sep 2012 17:02:43 -0400
changeset 12265 313e5a6f520b6d423191fb6330c8da57aecbab04
parent 12264 6d5b06e82381bd10e45ba740dd18060fbe9eedb3
child 12266 fc2a8fd24ed1bf531e0e500ed5feb9db6c973d8c
push id738
push userbugzilla@standard8.plus.com
push dateMon, 08 Oct 2012 19:38:39 +0000
treeherdercomm-aurora@6694e4ec3767 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwinton, mconley, IanN
bugs49474
Bug 49474 - Filter editor UI: make Enter key add a new criteria line instead of OK-ing the dialog. ui-r=bwinton, r=mconley, r=IanN
mail/base/content/mailWidgets.xml
mailnews/base/search/content/FilterEditor.js
suite/mailnews/mailWidgets.xml
--- a/mail/base/content/mailWidgets.xml
+++ b/mail/base/content/mailWidgets.xml
@@ -2191,17 +2191,18 @@
         this.initialize(document.getAnonymousNodes(this)[8], bundle);
 
         // initialize the tag list
         fillInTags();
       ]]>
       </constructor>
     </implementation>
     <handlers>
-      <handler event="keypress" keycode="VK_RETURN" action="onEnterInSearchTerm();"/>
+      <handler event="keypress" keycode="VK_RETURN" modifiers="accel any"
+               action="onEnterInSearchTerm(event);" preventdefault="true"/>
     </handlers>
   </binding>
 
   <!-- Folder picker helper widgets -->
   <binding id="popup-base" extends="chrome://global/content/bindings/popup.xml#popup">
     <implementation>
       <field name="tree" readonly="true">
         document.getAnonymousNodes(this)[0];
--- a/mailnews/base/search/content/FilterEditor.js
+++ b/mailnews/base/search/content/FilterEditor.js
@@ -130,19 +130,25 @@ function filterEditorOnLoad()
 }
 
 function filterEditorOnUnload()
 {
   if (gSessionFolderListenerAdded)
     MailServices.mailSession.RemoveFolderListener(gFolderListener);
 }
 
-function onEnterInSearchTerm()
+function onEnterInSearchTerm(event)
 {
-  // do nothing.  onOk() will get called since this is a dialog
+  if (event.ctrlKey || (Services.appinfo.OS == "Darwin" && event.metaKey)) {
+    // If accel key (Ctrl on Win/Linux, Cmd on Mac) was held too, accept the dialog.
+    document.getElementById("FilterEditor").acceptDialog();
+  } else {
+    // If only plain Enter was pressed, add a new rule line.
+    onMore(event);
+  }
 }
 
 function onAccept()
 {
   try {
     if (!saveFilter())
       return false;
   } catch(e) {Components.utils.reportError(e); return false;}
--- a/suite/mailnews/mailWidgets.xml
+++ b/suite/mailnews/mailWidgets.xml
@@ -1590,17 +1590,18 @@
         this.initialize(document.getAnonymousNodes(this)[8], bundle);
 
         // initialize the tag list
         fillInTags();
       ]]>
       </constructor>
     </implementation>
     <handlers>
-      <handler event="keypress" keycode="VK_RETURN" action="onEnterInSearchTerm();"/>
+      <handler event="keypress" keycode="VK_RETURN" modifiers="accel any"
+               action="onEnterInSearchTerm(event);" preventdefault="true"/>
     </handlers>
   </binding>
 
   <!-- Folder picker helper widgets -->
   <binding id="popup-base" extends="chrome://global/content/bindings/popup.xml#popup">
     <implementation>
       <field name="tree" readonly="true">
         document.getAnonymousNodes(this)[0];