Show right-click menus on form elements

Ever since bug 404536 has landed, a number of users have been angry.  What that bug did was removing the context menu for HTML form elements.  This change annoyed mainly two classes of users: those who were accustomed to those context menus, and those who used extensions which add menu items to the context menus for form elements (along with other elements, possibly), most notably, Firebug.

Exactly one year later, I am releasing the Form Control Context Menu extension, with the sole purpose of reverting back to the old behavior of showing the context menus for HTML form elements.  So, if you’ve been affected by this in the past, jump up and install this extension.  It can be installed on anything from Firefox 3.0 Beta 4 to the latest trunk builds.

Remember that the extension is currently in sandbox, so you need to log in before installing it.  Make sure to leave your comments if you find the extension useful, because moving it out of the sandbox needs your comment love. 

If you are an extension developer, and your extension adds something to those context menus, and is hence affected by that fix, you can either ask your users to install the Form Control Context Menu extension, or use the below code inside your own extension.  This code needs to run exactly once for each browser window, so you can add it to the load event handler of the XUL window.

let setTargetOriginal = nsContextMenu.prototype.setTarget;
nsContextMenu.prototype.setTarget = function(aNode, aRangeParent, aRangeOffset) {
  setTargetOriginal.apply(this, arguments);
  if (this.isTargetAFormControl(aNode))
    this.shouldDisplay = true;
};

For the curious, this is exactly the same code used inside the extension.  You can browse the extension’s source code on AMO, but there’s nothing too interesting there.

Posted in Blog Tagged with: , ,