home *** CD-ROM | disk | FTP | other *** search
/ PC World 2003 May / PCWorld_2003-05_cd.bin / Komunik / phoenix / chrome / toolkit.jar / content / global / widgets / checkbox.xml < prev    next >
Extensible Markup Language  |  2002-11-10  |  3KB  |  70 lines

  1. <?xml version="1.0"?>
  2.  
  3. <bindings id="checkboxBindings"
  4.    xmlns="http://www.mozilla.org/xbl"
  5.    xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  6.    xmlns:xbl="http://www.mozilla.org/xbl">
  7.  
  8.   <binding id="checkbox" extends="chrome://global/content/widgets/checkbox.xml#checkbox-baseline">
  9.     <resources>
  10.       <stylesheet src="chrome://global/skin/checkbox.css"/>
  11.     </resources>
  12.   </binding>
  13.  
  14.   <binding id="checkbox-baseline" extends="chrome://global/content/bindings/general.xml#basetext">
  15.     <content>
  16.       <xul:image class="checkbox-check" xbl:inherits="checked,disabled"/>
  17.       <xul:hbox class="checkbox-label-box" xbl:inherits="flex">
  18.         <xul:image class="checkbox-icon" xbl:inherits="src"/>
  19.         <xul:label class="checkbox-label" xbl:inherits="flex,xbl:text=label,accesskey,crop"/>
  20.       </xul:hbox>
  21.     </content>
  22.     
  23.     <implementation implements="nsIDOMXULCheckboxElement, nsIAccessibleProvider">
  24.       <property name="accessible">
  25.         <getter>
  26.           <![CDATA[
  27.             var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
  28.             return accService.createXULCheckboxAccessible(this);
  29.           ]]>
  30.         </getter>
  31.       </property>
  32.  
  33.       <method name="setChecked">
  34.         <parameter name="aValue"/>
  35.         <body>
  36.         <![CDATA[
  37.           var change = (aValue != (this.getAttribute('checked') == 'true'));
  38.           if (aValue) 
  39.             this.setAttribute('checked', 'true');
  40.           else 
  41.             this.removeAttribute('checked');
  42.           if (change) {
  43.             var event = document.createEvent('Events');
  44.             event.initEvent('CheckboxStateChange', false, true);
  45.             this.dispatchEvent(event);
  46.           }
  47.           return aValue;
  48.         ]]>
  49.         </body>
  50.       </method>
  51.       
  52.       <!-- public implementation -->
  53.       <property name="checked"    onset="return this.setChecked(val);"
  54.                                   onget="return this.getAttribute('checked') == 'true';"/>
  55.     </implementation>
  56.     
  57.     <handlers>
  58.       <!-- While it would seem we could do this by handling oncommand, we need can't
  59.            because any external oncommand handlers might get called before ours, and
  60.            then they would see the incorrect value of checked. -->           
  61.       <handler event="click" button="0" action="if (!this.disabled) this.checked = !this.checked;"/>
  62.       <handler event="keypress" key=" ">
  63.         <![CDATA[
  64.           this.checked = !this.checked;
  65.         ]]>
  66.       </handler>
  67.     </handlers>
  68.   </binding> 
  69.  
  70. </bindings>