【发布时间】:2012-12-26 19:15:58
【问题描述】:
我想从 XUL 设置对话框访问 simple-prefs 模块。我的代码如下所示。
var WINDOW = Cc["@mozilla.org/embedcomp/window-watcher;1"].getService(Ci.nsIWindowWatcher);
var mainWindow = MEDIATOR.getMostRecentWindow(null);
var pref = require("simple-prefs");
var win = WINDOW.openWindow(mainWindow, "chrome://myextension/content/settings.xul", "aboutMyExtension", "chrome,centerscreen,modal,dependant,dialog", pref);
如上所示,我将简单的首选项引用作为 xul 窗口的参数。 在 xul 页面中,我尝试以下操作来获取 simple-prefs 参考。
<script type="application/x-javascript" src="chrome://global/content/XPCNativeWrapper.js"/>
...
XPCNativeWrapper.unwrap(window.arguments[0])
window.arguments[0] 是 [xpconnect wrapped nsISupports],但 unwrap() 返回一个 [xpconnect wrapped nsISupports] 而不是实际解包。
那么,如何从 xul 对话框访问 simple-prefs 模块?
【问题讨论】:
-
您没有在插件代码和窗口之间来回传递事件=传递通道,因此即使您最初将值传递到窗口(作为数组或散列),您也会对首选项更改做出反应仍然存在问题。不知道,真的。
标签: javascript firefox-addon xul firefox-addon-sdk