Bug 742250 - Conversation items should be selectable without the mouse. r=bwinton.
authorFlorian Quèze <florian@queze.net>
Mon, 23 Jul 2012 15:14:18 -0400
changeset 10705 332fdeb276a1b7529e3d34d4c0a90814ca2e013b
parent 10704 3e83ef9a5b9bfa1306711e54f45e6ac0da39a9b6
child 10706 62a941631475965b45bfc5d09120c5544088c4ac
push id8075
push usermconley@mozilla.com
push dateMon, 23 Jul 2012 19:35:37 +0000
treeherdercomm-central@a7b28a555957 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwinton
bugs742250
Bug 742250 - Conversation items should be selectable without the mouse. r=bwinton.
mail/components/im/content/chat-messenger-overlay.js
--- a/mail/components/im/content/chat-messenger-overlay.js
+++ b/mail/components/im/content/chat-messenger-overlay.js
@@ -964,16 +964,30 @@ var chatHandler = {
     listbox.addEventListener("keypress", function(aEvent) {
       let item = listbox.selectedItem;
       if (!item || !item.parentNode) // empty list or item no longer in the list
         return;
       item.keyPress(aEvent);
     });
     listbox.addEventListener("select", this.onListItemSelected.bind(this));
     listbox.addEventListener("click", this.onListItemClick.bind(this));
+    document.getElementById("chatTabPanel").addEventListener("keypress", function(aEvent) {
+      let accelKeyPressed = Application.platformIsMac ? aEvent.metaKey : aEvent.ctrlKey;
+      if (!accelKeyPressed ||
+          (aEvent.keyCode != aEvent.DOM_VK_DOWN && aEvent.keyCode != aEvent.DOM_VK_UP))
+        return;
+      listbox._userSelecting = true;
+      listbox.moveByOffset(aEvent.keyCode == aEvent.DOM_VK_DOWN ? 1 : -1, true, false);
+      listbox._userSelecting = false;
+      let item = listbox.selectedItem;
+      if (item.localName == "imconv" && item.convView)
+        item.convView.focus();
+      else
+        listbox.focus();
+    });
     window.addEventListener("resize", this.onConvResize.bind(this));
     document.getElementById("conversationsGroup").sortComparator =
       function(a, b) a.title.toLowerCase().localeCompare(b.title.toLowerCase());
 
     // The initialization of the im core may trigger a master password prompt,
     // so wrap it with the async prompter service.
     Components.classes["@mozilla.org/messenger/msgAsyncPrompter;1"]
               .getService(Components.interfaces.nsIMsgAsyncPrompter)