0
votes

This is a condensed version of my code. I was trying to show a menu item in the right-click context menu of firefox.

Here gContextMenu is showing up as null, and it screws up the firefox's context menu. I found this out after 2 days of debugging.

<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<?xml-stylesheet href="chrome://foobar/skin/foobar.css" type="text/css"?>

<!DOCTYPE window SYSTEM "chrome://foobar/locale/foobar.dtd">

<overlay id="foobar-browser-overlay"
    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">



    <stringbundleset id="stringbundleset">
    <stringbundle id="foobar-string-bundle" src="chrome://foobar/locale/foobar.properties"/>
    </stringbundleset>

    <popup id="contentAreaContextMenu" onpopupshowing="alert(gContextMenu)">
        <menuseparator />
        <menuitem id="foobar-show-meaning" label="&foobar.showmeaning.label;"  />
    </popup>
</overlay>

Note:
I am referring to http://kb.mozillazine.org/Adding_items_to_menus to add a menuItem to the firefox's context menu, shown only when text is selected. But after debugging, the root cause is found to be gContextMenu is null.

  1. My firefox version is 19.0.2

  2. I don't want to use the new addon-sdk because it is bereft of finer controls which I plan to add later. (Finer controls like - controlling window size, its x,y co-ordinates)

  3. I am a novice when it comes to XUL development as of now..

  4. My references: https://developer.mozilla.org/en-US/docs/XUL/School_tutorial,
    https://developer.mozilla.org/en-US/docs/XUL/PopupGuide/Extensions,
    https://developer.mozilla.org/en-US/docs/XUL/PopupGuide/ContextMenus#Hiding_and_Showing_Menu_Items_based_on_Context
1

1 Answers

1
votes

The popup element has been deprecated long time ago, change your overlay accordingly

<menupopup id="contentAreaContextMenu"
...
</menupopup>

Also don't use the inline event handler, probably it overwrites the original. Add an event listener programmatically.