これは私のコードの要約版です。Firefox の右クリック コンテキスト メニューにメニュー項目を表示しようとしていました。
ここでgContextMenuが null として表示され、Firefox のコンテキスト メニューが台無しになります。2日間のデバッグの後にこれを見つけました。
<?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>
注: http://kb.mozillazine.org/Adding_items_to_menus
を
参照して、テキストが選択されている場合にのみ表示される、Firefox のコンテキスト メニューに menuItem を追加します。しかし、デバッグ後、根本的な原因は gContextMenu が null であることがわかりました。
私のFirefoxのバージョンは19.0.2です
新しい addon-sdk は使用したくありません。後で追加する予定のより細かい制御がないからです。(より細かい制御 - ウィンドウ サイズ、その x、y 座標の制御)
私は今のところ XUL 開発に関しては初心者です..
- 私の参照: 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