Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display hotkey in toolbar button's tooltip on Australis #136

Closed
Infocatcher opened this issue Mar 19, 2014 · 1 comment
Closed

Display hotkey in toolbar button's tooltip on Australis #136

Infocatcher opened this issue Mar 19, 2014 · 1 comment

Comments

@Infocatcher
Copy link
Owner

Built-in buttons:
resource://app/modules/CustomizableWidgets.jsm

    id: "privatebrowsing-button",
    shortcutId: "key_privatebrowsing",
function setAttributes(aNode, aAttrs) {
  ...
        let additionalArgs = [];
        if (aAttrs.shortcutId) {
          let shortcut = doc.getElementById(aAttrs.shortcutId);
          if (doc) {
            additionalArgs.push(ShortcutUtils.prettifyShortcut(shortcut));
          }
        }
        value = CustomizableUI.getLocalizedProperty({id: aAttrs.id}, stringId, additionalArgs);
      }
      aNode.setAttribute(name, value);
  ...
}

resource://app/modules/CustomizableUI.jsm

  getLocalizedProperty: function(aWidget, aProp, aFormatArgs, aDef) {
    ...
    try {
      if (Array.isArray(aFormatArgs) && aFormatArgs.length) {
        return gWidgetsBundle.formatStringFromName(name, aFormatArgs,
          aFormatArgs.length) || def;
      }
      return gWidgetsBundle.GetStringFromName(name) || def;
    } catch(ex) {
      if (!def) {
        ERROR("Could not localize property '" + name + "'.");
      }
    }
    ...
  },

Looks like we can't use this way, but now we have the main part: ShortcutUtils.prettifyShortcut().

@Infocatcher
Copy link
Owner Author

And yes, we have Ctrl+Alt+P in menu and Alt+Ctrl+P in tooltip.
Don't ask me, why, I just used API: key="idOfXULKeyNode" in menu and built-in ShortcutUtils.prettifyShortcut(XULKeyNode) to create tooltip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant