- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 XUL 编程的新手,我学到了很多东西,但我很难理解触发观察者通知并让另一个 XUL 窗口上的监听器从观察者函数中获取字符串值( observer 将字符串参数传递给其他 XUL 窗口)。
这是我的树 xil 文件。
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window title="ContactMatrix;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="fire.js" />
<hbox>
<textbox type="search" oncommand="SearchKeyword(this)"/>
</hbox>
<tree editable="false" id="my-tree" flex="1" seltype="cell" onclick="onTreeClicked(event)"
datasources="file://C:/mercredi.xml" ref="*" querytype="xml" enableColumnDrag="true" hidecolumnpicker="false" >
</tree>
</window>
这是我的脚本:
function SearchKeyword(oElem)
{
var filter = document.getElementById("filter");
filter.setAttribute("value", oElem.value);
document.getElementById("my-tree").builder.rebuild();
}
function onTreeClicked(event){
var tree = document.getElementById("my-tree");
var tbo = tree.treeBoxObject;
// get the row, col and child element at the point
var row = { }, col = { }, child = { };
tbo.getCellAt(event.clientX, event.clientY, row, col, child);
var cellText = tree.view.getCellText(row.value, col.value);
alert(cellText);
observe();
}
XPCOMUtils.defineLazyServiceGetter(this, "obsService", "@mozilla.org/observer-service;1", "nsIObserverService");
obsService.notifyObservers(null, "xulschoolhello-test-topic", cellText);
let observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
observerService.addObserver(testObserver, "xulschoolhello-test-topic", false);
let testObserver = {
observe : function(aSubject, aTopic, cellText) {
if (aTopic == "xulschoolhello-test-topic") {
window.alert("Data received: " + cellText); //cellText=aData
var textboxElement = document.getElementByID("ali");
textboxElement.value = cellText; // from the notification
}
}
}
var yourAddonObject = {
obsService: Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService),
register: function()
{
this.obsService.addObserver(this, "xulschoolhello-test-topic", false);
}
}
function DisplayContacts()
{
alert('opening file fire');
var windowObjectReference = window.openDialog("chrome://hello/content/fire.xul","fire");
}
这是我的文本框 XUL 文件。我想将 xul 树单元格值触发到此文件中的文本框。
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window title="Subjects import"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
<script type="application/x-javascript" src="fire.js" />
<groupbox>
<caption>Subject(s)</caption>
<hbox>
<label value="Subjects"/>
<textbox id='ali' value=""/>
<button label="Contacts" onclick="DisplayContacts();"/>
</hbox>
</groupbox>
</window>
我在将树单元值触发到我的另一个 XUL 窗口时遇到问题。从我的文本框 XUL 文件中,我可以打开我的树 XUL 文件,当我单击树单元格时,我可以获得树单元格的值作为警告消息。在那之后我的脚本不工作了。
基本上在这里,当我单击树单元格时,选定的树单元格值应该触发到我在另一个 XUl 窗口中的文本框。
请有人帮我解决这个问题。在这里,我将 scrip 文件和 xul 文件分开了。我从这个网站上获取了所有可能的脚本。 https://developer.mozilla.org/en/XUL_School/Observer_Notifications谢谢。注意:我在这里的同一篇文章中更新了我的问题。
最佳答案
在您发布的代码中,您在添加观察者之后定义了 testObserver,这意味着观察者不会调用您的观察函数,而是调用未定义函数的观察函数...您应该在添加观察者之前定义它,或者使用 testObserver.observe = function(){}
定义观察函数但是为了更简单地使用观察者,我会使用这个文件:
http://code.google.com/p/songbird-telescope/source/browse/trunk/modules/Observers.js?r=2
这是 nsIObserver 的包装器。
您只需要导入文件在您要发送和观察通知的两个文件中都有一个模块:
Components.utils.import('resource://modules/Observers.js');
您可以使用以下方式观察通知:
Observers.add('myTopic', myCallback, myCallbackSubject);
然后,每次执行以下行时,都会调用 myCallback,并将 parameterForMyCallback 作为参数:
Observers.notify('myTopic',parameterForMyCallback);
关于javascript - 如何触发观察者通知,并在另一个 XUL 窗口上设置监听器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6760613/
我刚刚安装了 songbird:它有一个很棒的用户界面。然后,我读到它是用 Mozilla Firefox 的核心 XUL 制作的。 好的,但我不明白:Songbird 是 Web 界面后面的桌面界面
我试图了解更彻底地学习 XUL 是否值得。 如果您有过中等复杂项目的经验(例如独立应用程序而不是 Firefox 扩展),您能告诉我您的经验吗? 我特别担心 XUL 框架本身不支持的功能。有两种可能性
简而言之:有什么方法可以找到 xul 应用程序的当前目录完整路径吗? 详细解释: 我想在 xul 浏览器应用程序中打开一些 html 文件。应该从 xul 应用程序以编程方式设置 html 文件的路径
在 Xul 中有没有比以下方法更简单的居中标签的方法? 最佳答案 是的。使用盒装通过 the pack attribute .
我熟悉客户端和服务器端的网络编程,我想扩展我的知识,以便能够编写一些桌面程序。 我的问题是我不太熟悉管理小部件的桌面方式。据我了解,在典型的桌面程序中,小部件有自己的生命,相互发送信号并通过回调对信号
我是 clean GUI 的 friend 。不幸的是,出于某种原因我需要覆盖“chrome://global/skin”样式表。 什么是最好的方法,将不同的基于操作系统的样式表实现到 xul 文档中
我束手无策,这可能很简单。基本上我有这个代码: var menuitem = document.getElementById('mymenuitem'); alert(menuitem); alert
我有一个我认为有用的 xul 应用程序,我想部署它。目标平台为Linux;我相信它也可以在 Windows/OSX 上运行,但尚未测试。部署此应用程序的最佳方式是什么? 使用 xpi 包并要求用户单独
我可以用LESS和Xul? 有没有人已经一起使用过它们? 最佳答案 我还没有看到任何人使用它,但没有什么能阻止你尝试。 LESS 只是一个预处理器,它输出 CSS 文件,因此您可能会发现的问题类型应该
是否可以更改显示在 XUL 元素中的制表符 (\t) 字符(当前为 8 个字符)的长度? 请注意,我想避免用空格替换 TAB。 最佳答案 CSS 2.1 规范指定制表符呈现为 8 个空格的宽度。 (
我有一个函数可以从 xul 文件(比如说 tree.xul)中获取所选复选框的值。在另一个 XUL 文件中有一个文本框,我想在其中传递所选复选框的值(标签值)(比如说 textbox.xul)。 最初
我计划为专有系统设计一个应用程序XUL & XPCOM。所以我决定使用 C/C++ 但作为这个领域的初学者我该如何开始开发我找不到一个好的开始指南。如果能给一些链接就好了和书籍。我还想知道如何防止用户
我最近接手了一个基于 XUL 的项目(独立,使用 xulrunner) - 但是我无法让它正常运行。 当我尝试使用命令行 ( xulrunner.exe ../application.ini -jsc
我的 XULRunner 应用程序有一个名为“Show Recordings”的按钮。按下它应该会导致 Windows 资源管理器为用户打开文件夹。我怎样才能做到这一点? 我在文件 I/O 文档中找不
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
您好,我想在 Firefox 3 中创建侧边栏,但不知道如何操作。 我在 MDC ( https://developer.mozilla.org/en/Creating_a_Firefox_sideb
我可以访问一个网站,该网站有一个简单的按钮(我不拥有该网站,也无权访问源代码)来下载文档。我正在使用下面的代码来执行它,它似乎工作正常但有问题 目标 我要下载文件 将文件数据发布到另一个站点 问题 有
在Delphi 2009应用程序中使用xulrunner(gecko sdk)v1.9.1.4127浏览器 它成功运行并打开了请求的页面,但是...没有图像!另外,在日志中,我可以看到,该服务器已将所
给定 仅应用了我的 CSS 定义中的部分样式。样式规则出现在 DOM 检查器中,但有些似乎被忽略。 这是样式定义,其中包含有关哪些类型的规则有效以及哪些类型被忽略的注释。 .ATKButton{
我尝试使用以下代码在运行时使用 vboxes 元素填充 hbox 元素: Xul 代码: Javascript代码: this.canvasContainer = document.getEl
我是一名优秀的程序员,十分优秀!