2012-12-26 38 views
0

我想從XUL設置對話框訪問simple-prefs模塊。我的代碼如下所示。從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); 

如上所示,我給簡單的prefs引用作爲參數給xul窗口。 在xul頁面中,我嘗試以下操作以獲取簡單首選項引用。

<script type="application/x-javascript" src="chrome://global/content/XPCNativeWrapper.js"/> 
... 
XPCNativeWrapper.unwrap(window.arguments[0]) 

window.arguments[0][xpconnect wrapped nsISupports],但解包()返回一個[xpconnect wrapped nsISupports],而不是實際展開它。

那麼,如何從xul對話框訪問simple-prefs模塊呢?

+0

您不必事件=傳遞通道來回插件代碼和窗口之間,這樣即使你通過值最初進入窗口(作爲一個數組或哈希),您仍然會對pref更改做出反應。不知道,真的。 – canuckistani

回答