xul elements -- broadcasterbroadcaster,顾名思义,就是广播者,是xul中一个有用的控件,任何控件只要配置ob
xul elements -- broadcaster
broadcaster,顾名思义,就是广播者,是xul中一个有用的控件,任何控件只要配置observes(观察)属性指向broadcaster的ID,即可获得广播信息。通常在一批对象需要共享同一个属性时,定义broadcaster,例如:disable和enable页面上的某些控件,见下面例子:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="findfile-window"???
title="Find Files"???
orient="horizontal"???
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script>
function changeUI()
{
?var btn = document.getElementById("buttonChangeUI");
?if(btn.label=='Disable')
?{
??btn.label = "Enable";
??document.getElementById("canEdit").setAttribute("disabled",true);
?}
?else
?{
??btn.label = "Disable";
??document.getElementById("canEdit").removeAttribute("disabled");
?}
}
</script>
? <broadcaster id="canEdit" />
<vbox>
<textbox id="textbox1" observes="canEdit"/>
<textbox id="textbox2" observes="canEdit"/>
<textbox id="textbox3" observes="canEdit"/>
<textbox id="textbox4" observes="canEdit"/>
<textbox id="textbox5" observes="canEdit"/>
<textbox id="textbox6" observes="canEdit"/>
<button id="buttonChangeUI" label="Disable" onclick="changeUI();"/>
</vbox>
</window>
broadcaster 还能放在broadcasterset中,broadcasterset是一个容器。