比较版本

XUL_教程/XBL介绍

修订版 274949:

由 Freebendy 在 进行的修订 274949

修订版 216553:

由 Freebendy 在 进行的修订 216553

标题:
XUL_教程/XBL介绍
XBL介绍
网址缩略名:
XUL_教程/XBL介绍
XUL_教程/XBL介绍
内容:

修订版 274949
修订版 216553
t7    <p>t
8      Introduction to XBL<br>
9      <br>
10      {{ PreviousNext("XUL Tutorial:Property Files", "XUL Tutoria
>l:Anonymous Content") }} 
11    </p>
12    <p>
13      &nbsp;
14    </p>
15    <p class="Textbody">
16      <span lang="EN-US" style='font-family: "Bitstream Vera Sans
> Mono";'>XUL</span><span style="font-family: 宋体;">有</span><span s 
>tyle="font-family: 宋体;">姐妹语言,</span><span lang="EN-US" style='fon 
>t-family: "Bitstream Vera Sans Mono";'>XBL(eXtensible Bindings La 
>nguage)</span><span style="font-family: 宋体;">。这种语言被用来声明</span><sp 
>an lang="EN-US" style='font-family: "Bitstream Vera Sans Mono";'> 
>XUL</span><span style="font-family: 宋体;">窗口控件的行为。</span><span lan 
>g="EN-US" style='font-family: "Bitstream Vera Sans Mono";'>&nbsp; 
></span> 
17    </p>
18    <p>
19      <br>
20      Bindings
21    </p>
22    <p class="Textbody">
23      <span style="font-family: 宋体;">您能够用</span><span lang="EN-US
>" style='font-family: "Bitstream Vera Sans Mono";'>XUL</span><spa 
>n style="font-family: 宋体;">来为应用程序定义用户界面的外观。您能对元素的外观应用样式。您也能通过改变样式 
>创建新的皮肤。所有元素的基础外观,比如滚动条和复选框,都能通过调整样式或设置元素参数进行修改。然而,</span><span la 
>ng="EN-US" style='font-family: "Bitstream Vera Sans Mono";'>XUL</ 
>span><span style="font-family: 宋体;">没有提供方法来改变元素工作的方式。例如,您想改变滚动条运行 
>的方式,需要用到</span><span lang="EN-US" style='font-family: "Bitstream  
>Vera Sans Mono";'>XBL</span><span style="font-family: 宋体;">。</spa 
>n><span lang="EN-US" style='font-family: "Bitstream Vera Sans Mon 
>o";'>&nbsp;</span> 
24    </p>
25    <p>
26      &nbsp;
27    </p>
28    <p class="Textbody">
29      <span style="font-family: 宋体;">一个</span><span lang="EN-US" 
>style='font-family: "Bitstream Vera Sans Mono";'>XBL</span><span  
>style="font-family: 宋体;">文件包含一组</span><span lang="EN-US" style='f 
>ont-family: "Bitstream Vera Sans Mono";'>binding</span><span styl 
>e="font-family: 宋体;">。每一个绑定描述了</span><span lang="EN-US" style='fo 
>nt-family: "Bitstream Vera Sans Mono";'>XUL</span><span style="fo 
>nt-family: 宋体;">控件的行为。例如,一个绑定可能与一个滚动条相连。这个行为,除了描述组成滚动条的</span><sp 
>an lang="EN-US" style='font-family: "Bitstream Vera Sans Mono";'> 
>XUL</span><span style="font-family: 宋体;">元素,还描述了滚动条的属性和方法。</span> 
><span lang="EN-US" style='font-family: "Bitstream Vera Sans Mono" 
>;'>&nbsp;</span> 
30    </p>
31    <p>
32      <br>
33      <span style='font-size:12.0pt;font-family:宋体; mso-ascii-fon
>t-family:"Bitstream Vera Sans Mono";mso-fareast-theme-font:minor- 
>fareast; mso-hansi-font-family:"Bitstream Vera Sans Mono";mso-bid 
>i-font-family:"Bitstream Vera Sans"; mso-ansi-language:EN-US;mso- 
>fareast-language:ZH-CN;mso-bidi-language:AR-SA'>类似</span><span la 
>ng="EN-US" style='font-size:12.0pt;font-family:"Bitstream Vera Sa 
>ns Mono"; mso-fareast-font-family:宋体;mso-fareast-theme-font:minor 
>-fareast;mso-bidi-font-family: "Bitstream Vera Sans";mso-ansi-lan 
>guage:EN-US;mso-fareast-language:ZH-CN; mso-bidi-language:AR-SA'> 
>XUL</span><span style='font-size:12.0pt;font-family: 宋体;mso-ascii 
>-font-family:"Bitstream Vera Sans Mono";mso-fareast-theme-font: m 
>inor-fareast;mso-hansi-font-family:"Bitstream Vera Sans Mono";mso 
>-bidi-font-family: "Bitstream Vera Sans";mso-ansi-language:EN-US; 
>mso-fareast-language:ZH-CN; mso-bidi-language:AR-SA'>,</span><spa 
>n lang="EN-US" style='font-size:12.0pt; font-family:"Bitstream Ve 
>ra Sans Mono";mso-fareast-font-family:宋体;mso-fareast-theme-font:  
>minor-fareast;mso-bidi-font-family:"Bitstream Vera Sans";mso-ansi 
>-language: EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:AR- 
>SA'>XBL</span><span style='font-size:12.0pt;font-family:宋体;mso-as 
>cii-font-family:"Bitstream Vera Sans Mono"; mso-fareast-theme-fon 
>t:minor-fareast;mso-hansi-font-family:"Bitstream Vera Sans Mono"; 
> mso-bidi-font-family:"Bitstream Vera Sans";mso-ansi-language:EN- 
>US;mso-fareast-language: ZH-CN;mso-bidi-language:AR-SA'>是</span>< 
>span lang="EN-US" style='font-size:12.0pt; font-family:"Bitstream 
> Vera Sans Mono";mso-fareast-font-family:宋体;mso-fareast-theme-fon 
>t: minor-fareast;mso-bidi-font-family:"Bitstream Vera Sans";mso-a 
>nsi-language: EN-US;mso-fareast-language:ZH-CN;mso-bidi-language: 
>AR-SA'>XML</span><span style='font-size:12.0pt;font-family:宋体;mso 
>-ascii-font-family:"Bitstream Vera Sans Mono"; mso-fareast-theme- 
>font:minor-fareast;mso-hansi-font-family:"Bitstream Vera Sans Mon 
>o"; mso-bidi-font-family:"Bitstream Vera Sans";mso-ansi-language: 
>EN-US;mso-fareast-language: ZH-CN;mso-bidi-language:AR-SA'>语言,因此它 
>有相似的语法规则。下述例子指出</span><span style='font-size:12.0pt;font-family:宋 
>体;mso-ascii-font-family:"Bitstream Vera Sans Mono"; mso-fareast-t 
>heme-font:minor-fareast;mso-hansi-font-family:"Bitstream Vera San 
>s Mono"; mso-bidi-font-family:"Bitstream Vera Sans";mso-ansi-lang 
>uage:EN-US;mso-fareast-language: ZH-CN;mso-bidi-language:AR-SA'>了 
></span><span lang="EN-US" style='font-size:12.0pt; font-family:"B 
>itstream Vera Sans Mono";mso-fareast-font-family:宋体;mso-fareast-t 
>heme-font: minor-fareast;mso-bidi-font-family:"Bitstream Vera San 
>s";mso-ansi-language: EN-US;mso-fareast-language:ZH-CN;mso-bidi-l 
>anguage:AR-SA'>XBL</span><span style='font-size:12.0pt;font-famil 
>y:宋体;mso-ascii-font-family:"Bitstream Vera Sans Mono"; mso-fareas 
>t-theme-font:minor-fareast;mso-hansi-font-family:"Bitstream Vera  
>Sans Mono"; mso-bidi-font-family:"Bitstream Vera Sans";mso-ansi-l 
>anguage:EN-US;mso-fareast-language: ZH-CN;mso-bidi-language:AR-SA 
>'>文件的基础结构:</span><br> 
34      <br>
35      &lt;?xml version="1.0"?&gt;<br>
36      &lt;bindings xmlns="<a class=" external" href="http://www.m
>ozilla.org/xbl" rel="freelink">http://www.mozilla.org/xbl</a>"&gt 
>;<br> 
37      &nbsp; &lt;binding id="binding1"&gt;<br>
38      &nbsp;&nbsp;&nbsp; &lt;!-- content, property, method and ev
>ent descriptions go here --&gt;<br> 
39      &nbsp; &lt;/binding&gt;<br>
40      &nbsp; &lt;binding id="binding2"&gt;<br>
41      &nbsp;&nbsp;&nbsp; &lt;!-- content, property, method and ev
>ent descriptions go here --&gt;<br> 
42      &nbsp; &lt;/binding&gt;<br>
43      &lt;/bindings&gt;
44    </p>
45    <p class="Textbody">
46      bindings<span style='font-family:宋体;mso-ascii-font-family:"
>Bitstream Vera Sans Mono"; mso-fareast-font-family:宋体;mso-fareast 
>-theme-font:minor-fareast;mso-hansi-font-family: "Bitstream Vera  
>Sans Mono"'>元素是</span><span lang="EN-US" style='font-family:"Bits 
>tream Vera Sans Mono"'>XBL</span><span style='font-family:宋体;mso- 
>ascii-font-family:"Bitstream Vera Sans Mono"; mso-fareast-font-fa 
>mily:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-famil 
>y: "Bitstream Vera Sans Mono"'>文件的根元素,它包含了一个或多个</span><span style 
>='font-family:宋体;mso-ascii-font-family:"Bitstream Vera Sans Mono" 
>; mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast 
>;mso-hansi-font-family: "Bitstream Vera Sans Mono"'>binding元素。每个< 
>/span>binding<span style='font-family:宋体;mso-ascii-font-family:"B 
>itstream Vera Sans Mono"; mso-fareast-font-family:宋体;mso-fareast- 
>theme-font:minor-fareast;mso-hansi-font-family: "Bitstream Vera S 
>ans Mono"'>元素声明了一个单独的</span> <span lang="EN-US" style='font-famil 
>y: "Bitstream Vera Sans Mono"'>binding</span><span style='font-fa 
>mily:宋体; mso-ascii-font-family:"Bitstream Vera Sans Mono";mso-far 
>east-font-family:宋体; mso-fareast-theme-font:minor-fareast;mso-han 
>si-font-family:"Bitstream Vera Sans Mono"'>,</span><span lang="EN 
>-US" style='font-family:"Bitstream Vera Sans Mono";color:#33CC66' 
>>ID</span><span style='font-family:宋体;mso-ascii-font-family:"Bits 
>tream Vera Sans Mono"; mso-fareast-font-family:宋体;mso-fareast-the 
>me-font:minor-fareast;mso-hansi-font-family: "Bitstream Vera Sans 
> Mono"'>属性能够用来确定</span> <span lang="EN-US" style='font-family: "B 
>itstream Vera Sans Mono"'>binding</span><span style='font-family: 
>宋体; mso-ascii-font-family:"Bitstream Vera Sans Mono";mso-fareast- 
>font-family:宋体; mso-fareast-theme-font:minor-fareast;mso-hansi-fo 
>nt-family:"Bitstream Vera Sans Mono"'>,就像上述的例子一样。模板有两个</span> <sp 
>an style='font-family:"Bitstream Vera Sans Mono"'><span lang="EN- 
>US" style="color:maroon">binding</span></span><span style='font-f 
>amily:宋体; mso-ascii-font-family:"Bitstream Vera Sans Mono";mso-fa 
>reast-font-family:宋体; mso-fareast-theme-font:minor-fareast;mso-ha 
>nsi-font-family:"Bitstream Vera Sans Mono"'>,分别叫做</span> <span st 
>yle='font-family:"Bitstream Vera Sans Mono"'><span lang="EN-US" s 
>tyle="color:#E6E64C">binding1</span></span><span style='font-fami 
>ly:宋体; mso-ascii-font-family:"Bitstream Vera Sans Mono";mso-farea 
>st-font-family:宋体; mso-fareast-theme-font:minor-fareast;mso-hansi 
>-font-family:"Bitstream Vera Sans Mono"'>,</span> <span style='fo 
>nt-family:"Bitstream Vera Sans Mono"'><span lang="EN-US" style="c 
>olor:#E6E64C">binding2</span></span><span style='font-family:宋体;  
>mso-ascii-font-family:"Bitstream Vera Sans Mono";mso-fareast-font 
>-family:宋体; mso-fareast-theme-font:minor-fareast;mso-hansi-font-f 
>amily:"Bitstream Vera Sans Mono"'>。一个可能与滚动条相联系,另一个与菜单联系。一个</span> 
> <span lang="EN-US" style='font-family:"Bitstream Vera Sans Mono" 
>'>binding</span><span style='font-family:宋体;mso-ascii-font-family 
>:"Bitstream Vera Sans Mono"; mso-fareast-font-family:宋体;mso-farea 
>st-theme-font:minor-fareast;mso-hansi-font-family: "Bitstream Ver 
>a Sans Mono"'>能够与任何的</span><span lang="EN-US" style='font-family: 
> "Bitstream Vera Sans Mono"'>XUL</span><span style='font-family:宋 
>体;mso-ascii-font-family: "Bitstream Vera Sans Mono";mso-fareast-f 
>ont-family:宋体;mso-fareast-theme-font: minor-fareast;mso-hansi-fon 
>t-family:"Bitstream Vera Sans Mono"'>元素相联系。如果您用</span> <span lang 
>="EN-US" style='font-family:"Bitstream Vera Sans Mono"'>CSS</span 
>><span style='font-family:宋体;mso-ascii-font-family:"Bitstream Ver 
>a Sans Mono"; mso-fareast-font-family:宋体;mso-fareast-theme-font:m 
>inor-fareast;mso-hansi-font-family: "Bitstream Vera Sans Mono"'>类 
>,就能用各种需要的不同的</span> <span lang="EN-US" style='font-family:"Bitstr 
>eam Vera Sans Mono"'>bindings</span><span style='font-family:宋体;m 
>so-ascii-font-family:"Bitstream Vera Sans Mono"; mso-fareast-font 
>-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-fa 
>mily: "Bitstream Vera Sans Mono"'>。注意上面模板中的</span>binding<span st 
>yle='font-family:宋体;mso-ascii-font-family:"Bitstream Vera Sans Mo 
>no"; mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fare 
>ast;mso-hansi-font-family: "Bitstream Vera Sans Mono"'>元素的命名空间。这声 
>明了我们使用的</span><span lang="EN-US" style='font-family:"Bitstream Ve 
>ra Sans Mono"'>XBL</span><span style='font-family:宋体;mso-ascii-fo 
>nt-family:"Bitstream Vera Sans Mono"; mso-fareast-font-family:宋体; 
>mso-fareast-theme-font:minor-fareast;mso-hansi-font-family: "Bits 
>tream Vera Sans Mono"'>的语法。</span> 
47    </p>
48    <p>
49      <br>
50      <span style='font-size:12.0pt;font-family:宋体; mso-ascii-fon
>t-family:"AR PL UMing CN";mso-hansi-font-family:"AR PL UMing CN"; 
> mso-bidi-font-family:"Bitstream Vera Sans";color:black;mso-ansi- 
>language:EN-US; mso-fareast-language:ZH-CN;mso-bidi-language:AR-S 
>A'>通过指定</span><span lang="EN-US" style='font-size:12.0pt;font-fam 
>ily:宋体;mso-fareast-theme-font:minor-fareast; mso-bidi-font-family 
>:"Bitstream Vera Sans";color:black;mso-ansi-language:EN-US; mso-f 
>areast-language:ZH-CN;mso-bidi-language:AR-SA'>css</span><span st 
>yle='font-size:12.0pt;font-family:宋体;mso-ascii-font-family:"AR PL 
> UMing CN"; mso-hansi-font-family:"AR PL UMing CN";mso-bidi-font- 
>family:"Bitstream Vera Sans"; color:black;mso-ansi-language:EN-US 
>;mso-fareast-language:ZH-CN;mso-bidi-language: AR-SA'>中</span><sp 
>an lang="EN-US" style='font-size:12.0pt;font-family:宋体; mso-farea 
>st-theme-font:minor-fareast;mso-bidi-font-family:"Bitstream Vera  
>Sans"; color:black;mso-ansi-language:EN-US;mso-fareast-language:Z 
>H-CN;mso-bidi-language: AR-SA'>-moz-binding</span><span style='fo 
>nt-size:12.0pt;font-family:宋体; mso-ascii-font-family:"AR PL UMing 
> CN";mso-hansi-font-family:"AR PL UMing CN"; mso-bidi-font-family 
>:"Bitstream Vera Sans";color:black;mso-ansi-language:EN-US; mso-f 
>areast-language:ZH-CN;mso-bidi-language:AR-SA'>的值为绑定文件的</span><sp 
>an lang="EN-US" style='font-size:12.0pt;font-family:宋体;mso-fareas 
>t-theme-font:minor-fareast; mso-bidi-font-family:"Bitstream Vera  
>Sans";color:black;mso-ansi-language:EN-US; mso-fareast-language:Z 
>H-CN;mso-bidi-language:AR-SA'>url</span><span style='font-size:12 
>.0pt;font-family:宋体;mso-ascii-font-family:"AR PL UMing CN"; mso-h 
>ansi-font-family:"AR PL UMing CN";mso-bidi-font-family:"Bitstream 
> Vera Sans"; color:black;mso-ansi-language:EN-US;mso-fareast-lang 
>uage:ZH-CN;mso-bidi-language: AR-SA'>,就可以把一个</span><span lang="EN 
>-US" style='font-size:12.0pt;font-family:宋体; mso-fareast-theme-fo 
>nt:minor-fareast;mso-bidi-font-family:"Bitstream Vera Sans"; colo 
>r:black;mso-ansi-language:EN-US;mso-fareast-language:ZH-CN;mso-bi 
>di-language: AR-SA'>binding</span><span style='font-size:12.0pt;f 
>ont-family:宋体;mso-ascii-font-family: "AR PL UMing CN";mso-hansi-f 
>ont-family:"AR PL UMing CN";mso-bidi-font-family: "Bitstream Vera 
> Sans";color:black;mso-ansi-language:EN-US;mso-fareast-language:  
>ZH-CN;mso-bidi-language:AR-SA'>绑定到元素上</span><span lang="EN-US" st 
>yle='font-size: 12.0pt;font-family:"AR PL UMing CN","serif";mso-f 
>areast-font-family:宋体; mso-bidi-font-family:"Bitstream Vera Sans" 
>;color:black;mso-ansi-language:EN-US; mso-fareast-language:ZH-CN; 
>mso-bidi-language:AR-SA'>.</span><span style='font-size:12.0pt;fo 
>nt-family:宋体;mso-ascii-font-family:"AR PL UMing CN"; mso-hansi-fo 
>nt-family:"AR PL UMing CN";mso-bidi-font-family:"Bitstream Vera S 
>ans"; color:black;mso-ansi-language:EN-US;mso-fareast-language:ZH 
>-CN;mso-bidi-language: AR-SA'>例如:</span><br> 
51      <br>
52      scrollbar {<br>
53      &nbsp;&nbsp;&nbsp; -moz-binding: url('<a class=" external" 
>href="chrome://findfile/content/findfile.xml#binding1'" rel="free 
>link">chrome://findfile/content/findfile.xml#binding1'</a>);<br> 
54      }<br>
55    </p>
56    <p class="Textbody">
57      <span lang="EN-US" style='font-family:"Bitstream Vera Sans 
>Mono"'>URL</span><span style='font-family:宋体;mso-ascii-font-famil 
>y:"Bitstream Vera Sans Mono"; mso-fareast-font-family:宋体;mso-fare 
>ast-theme-font:minor-fareast;mso-hansi-font-family: "Bitstream Ve 
>ra Sans Mono"'>指向</span><span lang="EN-US" style='font-family:"Bi 
>tstream Vera Sans Mono"'>'<a class=" external" href="chrome://fin 
>dfile/content/findfile.xml" rel="freelink">chrome://findfile/cont 
>ent/findfile.xml</a>'</span><span style='font-family:宋体;mso-ascii 
>-font-family:"Bitstream Vera Sans Mono"; mso-fareast-font-family: 
>宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family: "B 
>itstream Vera Sans Mono"'>文件中的</span><span lang="EN-US" style='fo 
>nt-family: "Bitstream Vera Sans Mono"'>'binding1'</span><span sty 
>le='font-family:宋体; mso-ascii-font-family:"Bitstream Vera Sans Mo 
>no";mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fare 
>ast;mso-hansi-font-family:"Bitstream Vera Sans Mono"'>。</span><sp 
>an lang="EN-US" style='font-family:"Bitstream Vera Sans Mono"'>&n 
>bsp;</span> 
58    </p>
59    <p class="Textbody">
60      <span lang="EN-US" style='font-family:"Bitstream Vera Sans 
>Mono"'>'#binding1'</span><span style='font-family:宋体;mso-ascii-fo 
>nt-family:"Bitstream Vera Sans Mono"; mso-fareast-font-family:宋体; 
>mso-fareast-theme-font:minor-fareast;mso-hansi-font-family: "Bits 
>tream Vera Sans Mono"'>语法用来指向特定的</span> <span lang="EN-US" style= 
>'font-family: "Bitstream Vera Sans Mono"'>binding</span><span sty 
>le='font-family:宋体; mso-ascii-font-family:"Bitstream Vera Sans Mo 
>no";mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fare 
>ast;mso-hansi-font-family:"Bitstream Vera Sans Mono"'>,这很像指向</spa 
>n><span lang="EN-US" style='font-family:"Bitstream Vera Sans Mono 
>"'>HTML</span><span style='font-family:宋体;mso-ascii-font-family:" 
>Bitstream Vera Sans Mono"; mso-fareast-font-family:宋体;mso-fareast 
>-theme-font:minor-fareast;mso-hansi-font-family: "Bitstream Vera  
>Sans Mono"'>文件的标签的方法。将所有的</span><span lang="EN-US" style='font-fa 
>mily:"Bitstream Vera Sans Mono"'>binding</span><span style='font- 
>family:宋体;mso-ascii-font-family:"Bitstream Vera Sans Mono"; mso-f 
>areast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-ha 
>nsi-font-family: "Bitstream Vera Sans Mono"'>放进一个简单文件的里。例中结果是</sp 
>an><span lang="EN-US" style='font-family:"Bitstream Vera Sans Mon 
>o"'>'binding1'</span><span style='font-family:宋体;mso-ascii-font-f 
>amily:"Bitstream Vera Sans Mono"; mso-fareast-font-family:宋体;mso- 
>fareast-theme-font:minor-fareast;mso-hansi-font-family: "Bitstrea 
>m Vera Sans Mono"'>将会描述所有的滚动条元素。如果您没用</span><span lang="EN-US" st 
>yle='font-family:"Bitstream Vera Sans Mono"'>-moz-binding URL</sp 
>an><span style='font-family:宋体;mso-ascii-font-family:"Bitstream V 
>era Sans Mono"; mso-fareast-font-family:宋体;mso-fareast-theme-font 
>:minor-fareast;mso-hansi-font-family: "Bitstream Vera Sans Mono"' 
>>中的标签,就会用到</span><span lang="EN-US" style='font-family: "Bitstrea 
>m Vera Sans Mono"'>XBL</span><span style='font-family:宋体;mso-asci 
>i-font-family: "Bitstream Vera Sans Mono";mso-fareast-font-family 
>:宋体;mso-fareast-theme-font: minor-fareast;mso-hansi-font-family:" 
>Bitstream Vera Sans Mono"'>文件中的第一个</span><span lang="EN-US" style 
>='font-family:"Bitstream Vera Sans Mono"'>binding</span><span sty 
>le='font-family:宋体;mso-ascii-font-family:"Bitstream Vera Sans Mon 
>o"; mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-farea 
>st;mso-hansi-font-family: "Bitstream Vera Sans Mono"'>。</span><sp 
>an lang="EN-US" style='font-family:"Bitstream Vera Sans Mono"'>&n 
>bsp;</span> 
61    </p>
62    <p>
63      &nbsp;
64    </p>
65    <p class="Textbody">
66      <span lang="EN-US" style='font-family:"Bitstream Vera Sans 
>Mono"'>binding</span><span style='font-family:宋体;mso-ascii-font-f 
>amily:"Bitstream Vera Sans Mono"; mso-fareast-font-family:宋体;mso- 
>fareast-theme-font:minor-fareast;mso-hansi-font-family: "Bitstrea 
>m Vera Sans Mono"'>声明了五种类型:</span><span lang="EN-US" style='font- 
>family: "Bitstream Vera Sans Mono"'>&nbsp;</span> 
67    </p>
68    <p>
69      <br>
70      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<span lang="EN-US" style='fo
>nt-family:"Bitstream Vera Sans Mono"; mso-fareast-font-family:"Bi 
>tstream Vera Sans Mono";mso-bidi-font-family:"Bitstream Vera Sans 
> Mono"'><span style="mso-list:Ignore">1.<span style='font:7.0pt " 
>Times New Roman"'>&nbsp;<span class="Apple-style-span" style="fon 
>t-size: 14px; font-family: Verdana; line-height: 23px;"><span sty 
>le='font-family:宋体;mso-ascii-font-family:"Bitstream Vera Sans Mon 
>o"; mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-farea 
>st;mso-hansi-font-family: "Bitstream Vera Sans Mono"'>内容:添加到</spa 
>n><span lang="EN-US" style='font-family: "Bitstream Vera Sans Mon 
>o"'>binding</span><span style='font-family:宋体; mso-ascii-font-fam 
>ily:"Bitstream Vera Sans Mono";mso-fareast-font-family:宋体; mso-fa 
>reast-theme-font:minor-fareast;mso-hansi-font-family:"Bitstream V 
>era Sans Mono"'>绑定到的元素的子元素</span></span></span></span></span> 
71    </p>
72    <p>
73      <span lang="EN-US" style='font-family:"Bitstream Vera Sans 
>Mono"; mso-fareast-font-family:"Bitstream Vera Sans Mono";mso-bid 
>i-font-family:"Bitstream Vera Sans Mono"'><span lang="EN-US" styl 
>e='font-family:"Bitstream Vera Sans Mono"; mso-fareast-font-famil 
>y:"Bitstream Vera Sans Mono";mso-bidi-font-family:"Bitstream Vera 
> Sans Mono"'><span style="mso-list:Ignore">&nbsp;&nbsp; &nbsp; &n 
>bsp;&nbsp;2.<span style='font:7.0pt "Times New Roman"'>&nbsp;</sp 
>an></span></span><span style='font-family:宋体;mso-ascii-font-famil 
>y:"Bitstream Vera Sans Mono"; mso-fareast-font-family:宋体;mso-fare 
>ast-theme-font:minor-fareast;mso-hansi-font-family: "Bitstream Ve 
>ra Sans Mono"'>属性:添加到</span><span lang="EN-US" style='font-family 
>: "Bitstream Vera Sans Mono"'>binding</span><span style='font-fam 
>ily:宋体; mso-ascii-font-family:"Bitstream Vera Sans Mono";mso-fare 
>ast-font-family:宋体; mso-fareast-theme-font:minor-fareast;mso-hans 
>i-font-family:"Bitstream Vera Sans Mono"'>绑定到的元素的属性。它们能通过脚本存取。</s 
>pan><span lang="EN-US" style='font-family:"Bitstream Vera Sans Mo 
>no"'>&nbsp;</span></span> 
74    </p>
75    <p class="Textbody" style="margin-left:35.35pt;text-indent:-1
>4.15pt;mso-list: l0 level1 lfo1"> 
76      <span lang="EN-US" style='font-family:"Bitstream Vera Sans 
>Mono"; mso-fareast-font-family:"Bitstream Vera Sans Mono";mso-bid 
>i-font-family:"Bitstream Vera Sans Mono"'><span style="mso-list:I 
>gnore">3.<span style='font:7.0pt "Times New Roman"'>&nbsp;</span> 
></span></span><span style='font-family:宋体;mso-ascii-font-family:" 
>Bitstream Vera Sans Mono"; mso-fareast-font-family:宋体;mso-fareast 
>-theme-font:minor-fareast;mso-hansi-font-family: "Bitstream Vera  
>Sans Mono"'>方法:添加到</span><span lang="EN-US" style='font-family: " 
>Bitstream Vera Sans Mono"'>binding</span><span style='font-family 
>:宋体; mso-ascii-font-family:"Bitstream Vera Sans Mono";mso-fareast 
>-font-family:宋体; mso-fareast-theme-font:minor-fareast;mso-hansi-f 
>ont-family:"Bitstream Vera Sans Mono"'>绑定到的元素的方法。它们能从脚本调用。</span> 
><span lang="EN-US" style='font-family:"Bitstream Vera Sans Mono"' 
>>&nbsp;</span> 
77    </p>
78    <p class="Textbody" style="margin-left:35.35pt;text-indent:-1
>4.15pt;mso-list: l0 level1 lfo1"> 
79      <span lang="EN-US" style='font-family:"Bitstream Vera Sans 
>Mono"; mso-fareast-font-family:"Bitstream Vera Sans Mono";mso-bid 
>i-font-family:"Bitstream Vera Sans Mono"'><span style="mso-list:I 
>gnore">4.</span></span><span style='font-family:宋体;mso-ascii-font 
>-family:"Bitstream Vera Sans Mono"; mso-fareast-font-family:宋体;ms 
>o-fareast-theme-font:minor-fareast;mso-hansi-font-family: "Bitstr 
>eam Vera Sans Mono"'>事件:元素将响应的例如鼠标单击和按键这类事件。</span> <span lang="E 
>N-US" style='font-family:"Bitstream Vera Sans Mono"'>binding</spa 
>n><span style='font-family:宋体;mso-ascii-font-family:"Bitstream Ve 
>ra Sans Mono"; mso-fareast-font-family:宋体;mso-fareast-theme-font: 
>minor-fareast;mso-hansi-font-family: "Bitstream Vera Sans Mono"'> 
>能添加脚本,来提供默认操作。另外,能够定义新事件。</span><span lang="EN-US" style='font-fa 
>mily:"Bitstream Vera Sans Mono"'>&nbsp;</span> 
80    </p>
81    <p class="Textbody" style="margin-left:35.35pt;text-indent:-1
>4.15pt;mso-list: l0 level1 lfo1"> 
82      <span lang="EN-US" style='font-family:"Bitstream Vera Sans 
>Mono"; mso-fareast-font-family:"Bitstream Vera Sans Mono";mso-bid 
>i-font-family:"Bitstream Vera Sans Mono"'><span style="mso-list:I 
>gnore">5.<span style='font:7.0pt "Times New Roman"'>&nbsp;</span> 
></span></span><span style='font-family:宋体;mso-ascii-font-family:" 
>Bitstream Vera Sans Mono"; mso-fareast-font-family:宋体;mso-fareast 
>-theme-font:minor-fareast;mso-hansi-font-family: "Bitstream Vera  
>Sans Mono"'>样式:</span><span lang="EN-US" style='font-family:"Bits 
>tream Vera Sans Mono"'>XBL</span><span style='font-family:宋体;mso- 
>ascii-font-family:"Bitstream Vera Sans Mono"; mso-fareast-font-fa 
>mily:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-famil 
>y: "Bitstream Vera Sans Mono"'>被定义的</span><span lang="EN-US" styl 
>e='font-family: "Bitstream Vera Sans Mono"'>binding</span><span s 
>tyle='font-family:宋体; mso-ascii-font-family:"Bitstream Vera Sans  
>Mono";mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fa 
>reast;mso-hansi-font-family:"Bitstream Vera Sans Mono"'>绑定到的元素拥有的 
>自定义样式的属性</span><span lang="EN-US" style='font-family:"Bitstream V 
>era Sans Mono"'>&nbsp;</span> 
83    </p>
84    <p>
85      <br>
86      Binding Example
87    </p>
88    <p class="Textbody">
89      <font class="Apple-style-span" color="#000000">Box</font><s
>pan style='font-family:宋体;mso-ascii-font-family:"Bitstream Vera S 
>ans Mono"; mso-fareast-font-family:宋体;mso-fareast-theme-font:mino 
>r-fareast;mso-hansi-font-family: "Bitstream Vera Sans Mono"'>很通用, 
>您能用它来创建自定义的窗口控件(虽然您能用任何元素,甚至自己构造的)。给一个</span><font class="Apple-s 
>tyle-span" color="#000000">box</font><span style='font-family:宋体; 
>mso-ascii-font-family:"Bitstream Vera Sans Mono"; mso-fareast-fon 
>t-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-f 
>amily: "Bitstream Vera Sans Mono"'>标签分配一个类属性,您就可以将</span> <span l 
>ang="EN-US" style='font-family:"Bitstream Vera Sans Mono"'>bindin 
>g</span><span style='font-family:宋体;mso-ascii-font-family:"Bitstr 
>eam Vera Sans Mono"; mso-fareast-font-family:宋体;mso-fareast-theme 
>-font:minor-fareast;mso-hansi-font-family: "Bitstream Vera Sans M 
>ono"'>连接到只属于该类的那些</span><span lang="EN-US" style='font-family:"Bi 
>tstream Vera Sans Mono"'>box</span><span style='font-family:宋体;ms 
>o-ascii-font-family:"Bitstream Vera Sans Mono"; mso-fareast-font- 
>family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-fam 
>ily: "Bitstream Vera Sans Mono"'>。请看下例:</span> 
90    </p>
91    <p>
92      <br>
93      XUL (example.xul):<br>
94      <br>
95      &lt;?xml version="1.0"?&gt;<br>
96      &lt;?xml-stylesheet href="<a class=" external" href="chrome
>://global/skin/" rel="freelink">chrome://global/skin/</a>" type=" 
>text/css"?&gt;<br> 
97      &lt;?xml-stylesheet href="<a class=" external" href="chrome
>://example/skin/example.css" rel="freelink">chrome://example/skin 
>/example.css</a>" type="text/css"?&gt;<br> 
98      <br>
99      &lt;window<br>
100      &nbsp;&nbsp;&nbsp;&nbsp; xmlns="<a class=" external" href="
>http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" re 
>l="freelink">http://www.mozilla.org/keymaster/gat...re.is.only.xu 
>l</a>"&gt;<br> 
101      &nbsp; &lt;box class="okcancelbuttons"/&gt;<br>
102      &lt;/window&gt;<br>
103      <br>
104      CSS (example.css):<br>
105      <br>
106      box.okcancelbuttons {<br>
107      &nbsp;&nbsp;&nbsp; -moz-binding: url('<a class=" external" 
>href="chrome://example/skin/example.xml#okcancel'" rel="freelink" 
>>chrome://example/skin/example.xml#okcancel'</a>);<br> 
108      }<br>
109      <br>
110      XBL (example.xml):<br>
111      <br>
112      &lt;?xml version="1.0"?&gt;<br>
113      &lt;bindings xmlns="<a class=" external" href="http://www.m
>ozilla.org/xbl" rel="freelink">http://www.mozilla.org/xbl</a>"<br 
>> 
114      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmlns:xul=
>"<a class=" external" href="http://www.mozilla.org/keymaster/gate 
>keeper/there.is.only.xul" rel="freelink">http://www.mozilla.org/k 
>eymaster/gat...re.is.only.xul</a>"&gt;<br> 
115      &nbsp; &lt;binding id="okcancel"&gt;<br>
116      &nbsp;&nbsp;&nbsp; &lt;content&gt;<br>
117      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xul:button label="OK"/&g
>t;<br> 
118      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xul:button label="Cancel
>"/&gt;<br> 
119      &nbsp;&nbsp;&nbsp; &lt;/content&gt;<br>
120      &nbsp; &lt;/binding&gt;<br>
121      &lt;/bindings&gt;
122    </p>
123    <p class="Textbody">
124      <span style='font-family:"Bitstream Vera Sans Mono"; mso-fa
>reast-font-family:"Bitstream Vera Sans Mono"'>这个例子创建了一个单<span lan 
>g="EN-US">box</span>的窗口,这个<span lang="EN-US">box</span>已经声明过含有一个  
><span lang="EN-US">okcancelbuttons</span>类。与文件相关的样式表阐述了含类<span la 
>ng="EN-US">okcancelbuttons</span>的<span lang="EN-US">box</span>有在 
><span lang="EN-US">XBL</span>文件中定义的特定的<span lang="EN-US">binding< 
>/span>。除</span><font class="Apple-style-span" color="#000000">box 
></font><span style='font-family:"Bitstream Vera Sans Mono";mso-fa 
>reast-font-family:"Bitstream Vera Sans Mono"'>之外,可用其它元素,甚至自定义的标签。 
></span> 
125    </p>
126    <p>
127      &nbsp;
128    </p>
129    <p class="Textbody">
130      <span lang="EN-US" style='font-family:"Bitstream Vera Sans 
>Mono"; mso-fareast-font-family:"Bitstream Vera Sans Mono"'>XBL</s 
>pan><span style='font-family:"Bitstream Vera Sans Mono";mso-farea 
>st-font-family:"Bitstream Vera Sans Mono"'>部分的细节将在下一章描述。然而,总结来说,它 
>使得在<span lang="EN-US">box</span>里自动增加了两个按钮。一个<span lang="EN-US">O 
>K</span>按钮,一个<span lang="EN-US">Cancel</span>按钮。<span lang="EN-US 
>">&nbsp;</span></span> 
131    </p>
132    <p>
133      <br>
134      <span style='font-size:12.0pt;font-family:宋体; mso-ascii-fon
>t-family:"Bitstream Vera Sans Mono";mso-fareast-theme-font:minor- 
>fareast; mso-hansi-font-family:"Bitstream Vera Sans Mono";mso-bid 
>i-font-family:"Bitstream Vera Sans"; mso-ansi-language:EN-US;mso- 
>fareast-language:ZH-CN;mso-bidi-language:AR-SA'>在下一节,我们将讲述用</span 
>><span lang="EN-US" style='font-size:12.0pt;font-family:"Bitstrea 
>m Vera Sans Mono"; mso-fareast-font-family:宋体;mso-fareast-theme-f 
>ont:minor-fareast;mso-bidi-font-family: "Bitstream Vera Sans";mso 
>-ansi-language:EN-US;mso-fareast-language:ZH-CN; mso-bidi-languag 
>e:AR-SA'>XBL</span><span style='font-size:12.0pt;font-family: 宋体; 
>mso-ascii-font-family:"Bitstream Vera Sans Mono";mso-fareast-them 
>e-font: minor-fareast;mso-hansi-font-family:"Bitstream Vera Sans  
>Mono";mso-bidi-font-family: "Bitstream Vera Sans";mso-ansi-langua 
>ge:EN-US;mso-fareast-language:ZH-CN; mso-bidi-language:AR-SA'>创建< 
>/span><span lang="EN-US" style='font-size:12.0pt; font-family:"Bi 
>tstream Vera Sans Mono";mso-fareast-font-family:宋体;mso-fareast-th 
>eme-font: minor-fareast;mso-bidi-font-family:"Bitstream Vera Sans 
>";mso-ansi-language: EN-US;mso-fareast-language:ZH-CN;mso-bidi-la 
>nguage:AR-SA'>content</span><span style='font-size:12.0pt;font-fa 
>mily:宋体;mso-ascii-font-family:"Bitstream Vera Sans Mono"; mso-far 
>east-theme-font:minor-fareast;mso-hansi-font-family:"Bitstream Ve 
>ra Sans Mono"; mso-bidi-font-family:"Bitstream Vera Sans";mso-ans 
>i-language:EN-US;mso-fareast-language: ZH-CN;mso-bidi-language:AR 
>-SA'>。</span><br> 
135      <br>
136      {{ PreviousNext("XUL Tutorial:Property Files", "XUL Tutoria
>l:Anonymous Content") }}<br> 
137      {{ languages( { "zh-cn":"cn/XUL_教程/XBL介绍","fr": "fr/Tutorie
>l_XUL/Introduction_\u00e0_XBL", "ja": "ja/XUL_Tutorial/Introducti 
>on_to_XBL", "pl": "pl/Kurs_XUL/Wprowadzenie_do_XBL" } ) }} 
138    </p>
139    <p>
140      &nbsp;
141    </p>

返回历史