Skip to content

Commit

Permalink
Version 1.0: Keyboard Navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
kewisch committed Oct 2, 2014
1 parent 1990409 commit 4b7e0c2
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
7 changes: 7 additions & 0 deletions chrome/content/quickmove-overlay.xul
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<textbox id="quickmove-textbox"
type="search"
timeout="500"
onfocus="quickmove.focus(event)"
onkeypress="quickmove.keypress(event, quickmove.executeMove)"
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-separator" class="quickmove-separator"/>
Expand All @@ -38,6 +39,7 @@
<textbox id="quickmove-copy-textbox"
type="search"
timeout="500"
onfocus="quickmove.focus(event)"
onkeypress="quickmove.keypress(event, quickmove.executeCopy)"
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-separator" class="quickmove-separator"/>
Expand All @@ -53,6 +55,7 @@
<textbox id="quickmove-filebutton-textbox"
type="search"
timeout="500"
onfocus="quickmove.focus(event)"
onkeypress="quickmove.keypress(event, quickmove.executeMove)"
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-filebutton-separator" class="quickmove-separator"/>
Expand All @@ -69,6 +72,7 @@
<textbox id="quickmove-textbox"
type="search"
timeout="500"
onfocus="quickmove.focus(event)"
onkeypress="quickmove.keypress(event, quickmove.executeMove)"
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-separator" class="quickmove-separator"/>
Expand All @@ -81,6 +85,7 @@
<textbox id="quickmove-textbox"
type="search"
timeout="500"
onfocus="quickmove.focus(event)"
onkeypress="quickmove.keypress(event, quickmove.executeGoto)"
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-goto-separator" class="quickmove-separator"/>
Expand All @@ -96,6 +101,7 @@
<textbox id="quickmove-textbox"
type="search"
timeout="500"
onfocus="quickmove.focus(event)"
onkeypress="quickmove.keypress(event, quickmove.executeMove)"
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-separator" class="quickmove-separator"/>
Expand All @@ -113,6 +119,7 @@
<textbox id="quickmove-textbox"
type="search"
timeout="500"
onfocus="quickmove.focus(event)"
onkeypress="quickmove.keypress(event, quickmove.executeGoto)"
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-location-separator" class="quickmove-separator"/>
Expand Down
2 changes: 2 additions & 0 deletions chrome/content/quickmove-postbox.xul
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<textbox id="quickmove-textbox"
type="search"
timeout="500"
onfocus="quickmove.focus(event)"
onkeypress="quickmove.keypress(event, quickmove.executeMove)"
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-separator" class="quickmove-separator"/>
Expand All @@ -55,6 +56,7 @@
<textbox id="quickmove-textbox"
type="search"
timeout="500"
onfocus="quickmove.focus(event)"
onkeypress="quickmove.keypress(event, quickmove.executeGoto)"
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-goto-separator" class="quickmove-separator"/>
Expand Down
34 changes: 30 additions & 4 deletions chrome/content/quickmove.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ var quickmove = {
* context menu is shown.
*/
popupshowing: function popupshowing(event) {
if (event.target.getAttribute("ignorekeys") != "true") {
// If we are showing the menuitems, then don't set up the folders but
// keep the old list.
return;
}

quickmove.clearItems(event.target);
quickmove.prepareFolders();

Expand All @@ -52,7 +58,12 @@ var quickmove = {

popupshown: function popupshown(event) {
// focus the textbox
event.target.firstChild.focus();
if (event.target.getAttribute("ignorekeys") == "true") {
event.target.firstChild.focus();
} else {
event.target.firstChild.blur();
event.target.setAttribute("ignorekeys", "true");
}
},

/**
Expand Down Expand Up @@ -290,6 +301,16 @@ var quickmove = {
}
},

focus: function(event) {
let popup = event.target.parentNode;
popup.setAttribute("ignorekeys", "true");

let x = popup.boxObject.screenX;
let y = popup.boxObject.screenY;
popup.hidePopup();
popup.openPopupAtScreen(x, y, true);
},

keypress: function keypress(event, executeFunc) {
let popup = event.target.parentNode;

Expand All @@ -307,8 +328,7 @@ var quickmove = {
if (event.keyCode == event.DOM_VK_ESCAPE) {
// On escape, cancel and close the popup.
quickmove.hide(popup);
} else if (event.keyCode == event.DOM_VK_ENTER ||
event.keyCode == event.DOM_VK_RETURN) {
} else if (event.keyCode == event.DOM_VK_RETURN) {
// If the user presses enter, execute the passed action, either directly
// or indirectly
if (quickmove.dirty) {
Expand All @@ -322,6 +342,13 @@ var quickmove = {

// Now hide the popup
quickmove.hide(popup);
} else if (event.keyCode == event.DOM_VK_DOWN) {
popup.removeAttribute("ignorekeys");

let x = popup.boxObject.screenX;
let y = popup.boxObject.screenY;
popup.hidePopup();
popup.openPopupAtScreen(x, y, true);
} else {
// If something was typed, then remember that we haven't searched yet.
quickmove.dirty = true;
Expand Down Expand Up @@ -358,7 +385,6 @@ var quickmove = {
} else {
Components.utils.reportError("Couldn't find a node to open the panel on");
}

},

openGoto: function openGoto() {
Expand Down
2 changes: 1 addition & 1 deletion chrome/locales/en-US/amo.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ Use the keyboard to quickly move messages and navigate folders. First of all, us
Then enter parts of the folder you want to move the message to. Pressing Enter will move the message to the first entry in the search results. If you'd rather use the context menus, the Move To/Copty To context menus have also been modified to use the quick folder move menu.

<b>KNOWN ISSUES</b>
Unfortunately using the keyboard to navigate between the menu items in the dropdown is hindered by bugs in the Mozilla Platform. I have a workaround in progress, please stay tuned. Until then, you will have to enter a more unique portion of your folder name.
Due to an issue with the Mozilla platform, keyboard navigation in the popup will not behave natural. Unfortunately there is currently no better solution, but a certain level of keyboard navigation is possible. After entering text in the search box, you may press the down arrow to switch to the menuitems. In this moment the popup will flicker, since its being reopened. Pressing the down arrow once more will allow you to select a menuitem.

Using Shift+G to open a folder not shown in the view uses a Thunderbird native function to select the folder. This function changes to the default view (all folders) if the folder is not visible (i.e contains no unread messages).
2 changes: 1 addition & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>[email protected]</em:id>
<em:type>2</em:type>
<em:version>0.13</em:version>
<em:version>1.0</em:version>

<em:name>Quick Folder Move</em:name>
<em:description>Quickly move messages into other folders using the keyboard</em:description>
Expand Down

0 comments on commit 4b7e0c2

Please sign in to comment.