Friday, April 01, 2011

GM_registerMenuCommand() losing "accelerator key" feature

Script authors, take note: I'm planning on moving forward with a change to remove a small part of the functionality of GM_registerMenuCommand(). This post is to explain what part, and the justification for doing so.

With the release of Firefox 4, Mozilla has made some grand changes to the look and feel of the browser. They've moved tabs to the top, emphasized the Firefox Button over the menu bar, and removed the status bar (providing the addons bar as a temporary shim for extension compatibility). This led us to re-build parts of Greasemonkey to focus on providing a toolbar, and de-emphasize the old "monkey menu" in the status bar.

It turns out that the menu code, now controlling the Tools > Greasemonkey menu, the old status bar monkey menu (in Firefox 3.x), and the new toolbar button's menu, also controls the commands for GM_registerMenuCommand() (to put them in the menu, of course!), which also controls the "accelerator keys" for those commands.

These accelerator keys have, more or less, never worked. I've written a test script (see the source, or install it) to demonstrate this. Once installed, navigate to the page about:blank#GM_rmc (you might need to hit reload, depending on how you open this) to run the script. Pick any combination of modifiers, and a letter for the accelerator key. Then try to use that accelerator key.

I'm testing on Firefox 3.6 and Greasemonkey 0.8 -- the last versions before some of these big changes started, where everything should still be as reliable as it ever was.

I ran this test: Close Firefox, launch it to the test page with only one tab open. Register a single menu command. Open the monkey menu, click on the menu item and see the alert. Press the accelerator key. No alert. I repeated this whole process for: Shift+Ctrl+Q, Alt+Shift+X, Control+M. None of it works. I saw it working with at least one earlier attempt, but even then it was fragile: normal actions like loading pages or closing tabs caused otherwise working keys to fail.

I tried a super-simple script and it too doesn't work. Installing it and pressing Ctrl+Shift+C gives me no results, but selecting the menu item does.

I've asked on our mailing list, I've asked at userscripts.org, and I've held discussions with developers. I can't find anyone that will regret losing accelerator key support in GM_registerMenuCommand(), and all my attempts to make it work well have so far failed.

So it is going to be removed, in Greasemonkey 0.9.2. Unless I hear from someone that can show me that I've been a fool, it does work, and I'm using it wrong. Please use the mailing list to get in touch with us if so!

1 comment:

  1. P.S. First: the day of the year has no bearing on this post. Second: please do not confuse accelerator key with access key. The access key is remaining as-is.

    ReplyDelete