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
--- 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];