MozillaZine

keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
darknight13
 
Posts: 1
Joined: September 17th, 2012, 2:38 am

Post Posted December 10th, 2019, 2:10 am

I figured out some of what I want to accomplish but not enough, please help me fill the gaps. Pointers to relevant references are ok, couldn't find much on my own. I may also be wrong about what I'm doing right now since my JS is practically zero.

The following code basically replaces the content of changeMessageViewShortcuts() from previous post (thanks highfalutin!).
Code: Select all
changeKeyStrokeForKeyId("select previous message", "ArrowLeft", null, "alt");
changeKeyStrokeForKeyId("select next message", "ArrowRight", null, "alt");
changeKeyStrokeForKeyId("scroll pane up one line", "ArrowUp", null, "alt");
changeKeyStrokeForKeyId("scroll pane down one line", "ArrowDown", null, "alt");
changeKeyStrokeForKeyId("scroll pane up one page", "PageUp", null, "alt");
changeKeyStrokeForKeyId("scroll pane down one page", "PageDown", null, "alt");

Cleverson
 
Posts: 12
Joined: March 11th, 2009, 3:09 pm

Post Posted January 10th, 2020, 12:18 pm

Hello all,

I really hope someone is able to release a version of KeyConfig compatible with Thunderbird 68 and later. Today I use this extension for 3 purposes:
1. I have a custom code for first letter navigation across folders;
2. I have a custom code to jump straight to the next folder containing unread messages;
3. I've disabled some keys like s for starring and a for archiving messages, as well as changed some keys to others which resemble the old MS Outlook Express.

AFAIC, only the first of my needs above could be served by another extension such as QuickFolder.

Until Keyconfig is not ready for TB 68, I'm not upgrading...

bege
 
Posts: 121
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Post Posted January 14th, 2020, 9:08 am

Hi,
I tried to use the posted keybindings script in TB 68.4.1 to replace the extension that closed the current tab with ESC.

The used oncommand
Code: Select all
"document.getElementById('tabmail').closeTab(document.popupNode);"

works if I enter it in the error console, but in the script it does not work.
I tried VK_ESCAPE, that does nothing
VK_F1 does not unbind F1, pressing F1 still opens TB help.
Code: Select all
    /* Thunderbird userChrome.js */

    (function () {

      /* List of common chrome urls:
       *
       * 3pane window > chrome://messenger/content/messenger.xul
       * message window > chrome://messenger/content/messageWindow.xul
       * compose window > chrome://messenger/content/messengercompose/messengercompose.xul
       * address book window > chrome://messenger/content/addressbook/addressbook.xul
       * prompt window > chrome://global/content/commonDialog.xul
       *
       */

      if (location == "chrome://messenger/content/messenger.xul") {
        setTimeout(function () {
          try {

            /* unbind Help F1 */

            var keyset = document.getElementById("mailKeys");
            var key = document.getElementById("key_openHelp");
            keyset.removeChild(key);

            /* bind Example F1 */

            // window.key_example = function (event) {
              // alert("Example 1");
            };
            var keyset = document.getElementById("mailKeys");
            var key = document.createElement("key");
            key.setAttribute("id", "key_TBcloseTab");
         // key.setAttribute("key", "A"); // A
         // key.setAttribute("modifiers", "control,shift"); // Ctrl+Shift
         // key.setAttribute("modifiers", "alt"); // Alt
            key.setAttribute("keycode", "VK_F1"); // F1
         // key.setAttribute("command", "cmd_toggleQuickFilterBar");
            key.setAttribute("oncommand", "document.getElementById('tabmail').closeTab(document.popupNode);");
         // key.setAttribute("oncommand", "alert('Example 2');");
            keyset.appendChild(key);

          } catch (e) {
            Components.utils.reportError(e);
          };
        }, 1000);
      }
      if (location == "chrome://messenger/content/messageWindow.xul") {}
      if (location == "chrome://messenger/content/messengercompose/messengercompose.xul") {}
      if (location == "chrome://messenger/content/addressbook/addressbook.xul") {}
      if (location == "chrome://global/content/commonDialog.xul") {}

    })();

Can someone help? Thank you very much.

morat
 
Posts: 3582
Joined: February 3rd, 2009, 6:29 pm

Post Posted January 14th, 2020, 10:41 am

There is a syntax error in your script because you forgot to comment out the line below the "Example 1" line.

Syntax Validator
http://esprima.org/demo/validate.html

The document.popupNode property should be null outside a context menu.

document.popupNode
http://developer.mozilla.org/docs/Web/API/Document/popupNode

Try this:

Code: Select all
/* Thunderbird userChrome.js */

(function () {

  if (location == "chrome://messenger/content/messenger.xul") {
    setTimeout(function () {
      try {

        // unbind Close Quick Filter Bar ESC
        var keyset = document.getElementById("mailKeys");
        var key = document.getElementById("key_qfb_escape");
        keyset.removeChild(key);

        // bind Close Tab Esc
        var keyset = document.getElementById("mailKeys");
        var key = document.createXULElement("key");
        key.setAttribute("id", "__unique_identifier_key_close_tab");
        key.setAttribute("keycode", "VK_ESCAPE");
        key.setAttribute("oncommand", "document.getElementById('tabmail').closeTab();");
        keyset.appendChild(key);

      } catch (e) {
        Components.utils.reportError(e);
      };
    }, 1000);
  }

})();

userChromeJS 0.0.5
Thunderbird 68.4.1
Windows 7 SP1 32-bit

P.S.

Close Tab on ESC
http://addons.thunderbird.net/thunderbird/addon/161748
http://addons.thunderbird.net/thunderbird/addon/987733

bege
 
Posts: 121
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Post Posted January 14th, 2020, 11:57 am

Thank you so much for your help, morat, both for the code and the validator link.

What does your comment on document.popupNode relate to in this context?

Today I searched for a compatible extension and didn't find it, you did. :smile:
I will stick with your script.

morat
 
Posts: 3582
Joined: February 3rd, 2009, 6:29 pm

Post Posted January 14th, 2020, 1:36 pm

I was just commenting that the document.popupNode property isn't useful in a keyboard shortcut.

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 5 guests