Disable the Addon Bar context menu on Addon SDK widgets

UPDATE: This bug was fixed in Addon SDK 1.6, so this workaround isn't needed anymore.

If you’ve tried adding right click support to a widget when using Mozilla’s Addon SDK, you’ve probably noticed that the Addon Bar context menu appears when you right click on your widget. This is quite annoying, but thankfully the workaround is as simple as preventing the default action of the contextmenu event.

Just add the following code to your widget’s content script to prevent a context menu from showing when right clicking on your widget:

this.addEventListener('contextmenu', function (event) {
}, false);

GitHub Comments

add comment via GitHub