toolkit/content/widgets/menulist.xml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/content/widgets/menulist.xml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,618 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<!-- This Source Code Form is subject to the terms of the Mozilla Public
     1.6 +   - License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 +   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
     1.8 +
     1.9 +
    1.10 +<bindings id="menulistBindings"
    1.11 +   xmlns="http://www.mozilla.org/xbl"
    1.12 +   xmlns:html="http://www.w3.org/1999/xhtml"
    1.13 +   xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.14 +   xmlns:xbl="http://www.mozilla.org/xbl">
    1.15 +
    1.16 +  <binding id="menulist-base" extends="chrome://global/content/bindings/general.xml#basecontrol">
    1.17 +    <resources>
    1.18 +      <stylesheet src="chrome://global/content/menulist.css"/>
    1.19 +      <stylesheet src="chrome://global/skin/menulist.css"/>
    1.20 +    </resources>
    1.21 +  </binding>
    1.22 +
    1.23 +  <binding id="menulist" display="xul:menu" role="xul:menulist"
    1.24 +           extends="chrome://global/content/bindings/menulist.xml#menulist-base">
    1.25 +    <content sizetopopup="pref">
    1.26 +      <xul:hbox class="menulist-label-box" flex="1">
    1.27 +        <xul:image class="menulist-icon" xbl:inherits="src=image,src"/>
    1.28 +        <xul:label class="menulist-label" xbl:inherits="value=label,crop,accesskey" crop="right" flex="1"/>
    1.29 +      </xul:hbox>
    1.30 +      <xul:dropmarker class="menulist-dropmarker" type="menu" xbl:inherits="disabled,open"/>
    1.31 +      <children includes="menupopup"/>
    1.32 +    </content>
    1.33 +
    1.34 +    <handlers>
    1.35 +      <handler event="command" phase="capturing"
    1.36 +        action="if (event.target.parentNode.parentNode == this) this.selectedItem = event.target;"/>
    1.37 +
    1.38 +      <handler event="popupshowing">
    1.39 +        <![CDATA[
    1.40 +          if (event.target.parentNode == this) {
    1.41 +            this.menuBoxObject.activeChild = null;
    1.42 +            if (this.selectedItem)
    1.43 +              // Not ready for auto-setting the active child in hierarchies yet.
    1.44 +              // For now, only do this when the outermost menupopup opens.
    1.45 +              this.menuBoxObject.activeChild = this.mSelectedInternal;
    1.46 +          }
    1.47 +        ]]>
    1.48 +      </handler>
    1.49 +
    1.50 +      <handler event="keypress" modifiers="shift any" group="system">
    1.51 +        <![CDATA[
    1.52 +          if (!event.defaultPrevented &&
    1.53 +              (event.keyCode == KeyEvent.DOM_VK_UP ||
    1.54 +               event.keyCode == KeyEvent.DOM_VK_DOWN ||
    1.55 +               event.keyCode == KeyEvent.DOM_VK_PAGE_UP ||
    1.56 +               event.keyCode == KeyEvent.DOM_VK_PAGE_DOWN ||
    1.57 +               event.keyCode == KeyEvent.DOM_VK_HOME ||
    1.58 +               event.keyCode == KeyEvent.DOM_VK_END ||
    1.59 +               event.keyCode == KeyEvent.DOM_VK_BACK_SPACE ||
    1.60 +               event.charCode > 0)) {
    1.61 +            // Moving relative to an item: start from the currently selected item
    1.62 +            this.menuBoxObject.activeChild = this.mSelectedInternal;
    1.63 +            if (this.menuBoxObject.handleKeyPress(event)) {
    1.64 +              this.menuBoxObject.activeChild.doCommand();
    1.65 +              event.preventDefault();
    1.66 +            }
    1.67 +          }
    1.68 +        ]]>
    1.69 +      </handler>
    1.70 +    </handlers>
    1.71 +
    1.72 +    <implementation implements="nsIDOMXULMenuListElement, nsIDOMEventListener">
    1.73 +      <constructor>
    1.74 +        this.mInputField = null;
    1.75 +        this.mSelectedInternal = null;
    1.76 +        this.menuBoxObject = this.boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject);
    1.77 +        this.setInitialSelection();
    1.78 +      </constructor>
    1.79 +
    1.80 +      <method name="setInitialSelection">
    1.81 +        <body>
    1.82 +          <![CDATA[
    1.83 +            var popup = this.menupopup;
    1.84 +            if (popup) {
    1.85 +              var arr = popup.getElementsByAttribute('selected', 'true');
    1.86 +
    1.87 +              var editable = this.editable;
    1.88 +              var value = this.value;
    1.89 +              if (!arr.item(0) && value)
    1.90 +                arr = popup.getElementsByAttribute(editable ? 'label' : 'value', value);
    1.91 +
    1.92 +              if (arr.item(0))
    1.93 +                this.selectedItem = arr[0];
    1.94 +              else if (!editable)
    1.95 +                this.selectedIndex = 0;
    1.96 +            }
    1.97 +          ]]>
    1.98 +        </body>
    1.99 +      </method>
   1.100 +
   1.101 +      <property name="value" onget="return this.getAttribute('value');">
   1.102 +        <setter>
   1.103 +          <![CDATA[
   1.104 +            // if the new value is null, we still need to remove the old value
   1.105 +            if (val == null)
   1.106 +              return this.selectedItem = val;
   1.107 +
   1.108 +            var arr = null;
   1.109 +            var popup = this.menupopup;
   1.110 +            if (popup)
   1.111 +              arr = popup.getElementsByAttribute('value', val);
   1.112 +
   1.113 +            if (arr && arr.item(0))
   1.114 +              this.selectedItem = arr[0];
   1.115 +            else {
   1.116 +              this.selectedItem = null;
   1.117 +              this.setAttribute('value', val);
   1.118 +            }
   1.119 +
   1.120 +            return val;
   1.121 +          ]]>
   1.122 +        </setter>
   1.123 +      </property>
   1.124 +
   1.125 +      <property name="inputField" readonly="true" onget="return null;"/>
   1.126 +
   1.127 +      <property name="crop" onset="this.setAttribute('crop',val); return val;"
   1.128 +                            onget="return this.getAttribute('crop');"/>
   1.129 +      <property name="image"  onset="this.setAttribute('image',val); return val;"
   1.130 +                              onget="return this.getAttribute('image');"/>
   1.131 +      <property name="label" readonly="true" onget="return this.getAttribute('label');"/>
   1.132 +      <property name="description" onset="this.setAttribute('description',val); return val;"
   1.133 +                                   onget="return this.getAttribute('description');"/>
   1.134 +      <property name="editable"  onset="this.setAttribute('editable',val); return val;"
   1.135 +                                 onget="return this.getAttribute('editable') == 'true';"/>
   1.136 +
   1.137 +      <property name="open" onset="this.menuBoxObject.openMenu(val);
   1.138 +                                   return val;"
   1.139 +                            onget="return this.hasAttribute('open');"/>
   1.140 +
   1.141 +      <property name="itemCount" readonly="true"
   1.142 +                onget="return this.menupopup ? this.menupopup.childNodes.length : 0"/>
   1.143 +
   1.144 +      <property name="menupopup" readonly="true">
   1.145 +        <getter>
   1.146 +          <![CDATA[
   1.147 +            var popup = this.firstChild;
   1.148 +            while (popup && popup.localName != "menupopup")
   1.149 +              popup = popup.nextSibling;
   1.150 +            return popup;
   1.151 +          ]]>
   1.152 +        </getter>
   1.153 +      </property>
   1.154 +
   1.155 +      <method name="contains">
   1.156 +        <parameter name="item"/>
   1.157 +        <body>
   1.158 +          <![CDATA[
   1.159 +            if (!item)
   1.160 +              return false;
   1.161 +
   1.162 +            var parent = item.parentNode;
   1.163 +            return (parent && parent.parentNode == this);
   1.164 +          ]]>
   1.165 +        </body>
   1.166 +      </method>
   1.167 +
   1.168 +      <property name="selectedIndex">
   1.169 +        <getter>
   1.170 +          <![CDATA[
   1.171 +            // Quick and dirty. We won't deal with hierarchical menulists yet.
   1.172 +            if (!this.selectedItem ||
   1.173 +                !this.mSelectedInternal.parentNode ||
   1.174 +                this.mSelectedInternal.parentNode.parentNode != this)
   1.175 +              return -1;
   1.176 +
   1.177 +            var children = this.mSelectedInternal.parentNode.childNodes;
   1.178 +            var i = children.length;
   1.179 +            while (i--)
   1.180 +              if (children[i] == this.mSelectedInternal)
   1.181 +                break;
   1.182 +
   1.183 +            return i;
   1.184 +          ]]>
   1.185 +        </getter>
   1.186 +        <setter>
   1.187 +          <![CDATA[
   1.188 +            var popup = this.menupopup;
   1.189 +            if (popup && 0 <= val) {
   1.190 +              if (val < popup.childNodes.length)
   1.191 +                this.selectedItem = popup.childNodes[val];
   1.192 +            }
   1.193 +            else
   1.194 +              this.selectedItem = null;
   1.195 +            return val;
   1.196 +          ]]>
   1.197 +        </setter>
   1.198 +      </property>
   1.199 +
   1.200 +      <property name="selectedItem">
   1.201 +        <getter>
   1.202 +          <![CDATA[
   1.203 +            return this.mSelectedInternal;
   1.204 +          ]]>
   1.205 +        </getter>
   1.206 +        <setter>
   1.207 +          <![CDATA[
   1.208 +            var oldval = this.mSelectedInternal;
   1.209 +            if (oldval == val)
   1.210 +              return val;
   1.211 +
   1.212 +            if (val && !this.contains(val))
   1.213 +              return val;
   1.214 +
   1.215 +            if (oldval) {
   1.216 +              oldval.removeAttribute('selected');
   1.217 +              if (document instanceof Components.interfaces.nsIDOMXULDocument) {
   1.218 +                document.removeBroadcastListenerFor(oldval, this, "value");
   1.219 +                document.removeBroadcastListenerFor(oldval, this, "label");
   1.220 +                document.removeBroadcastListenerFor(oldval, this, "image");
   1.221 +                document.removeBroadcastListenerFor(oldval, this, "description");
   1.222 +              }
   1.223 +              else
   1.224 +                oldval.removeEventListener("DOMAttrModified", this, false);
   1.225 +            }
   1.226 +
   1.227 +            this.mSelectedInternal = val;
   1.228 +            if (val) {
   1.229 +              val.setAttribute('selected', 'true');
   1.230 +              this.setAttribute('value', val.getAttribute('value'));
   1.231 +              this.setAttribute('image', val.getAttribute('image'));
   1.232 +              this.setAttribute('label', val.getAttribute('label'));
   1.233 +              this.setAttribute('description', val.getAttribute('description'));
   1.234 +              // DOMAttrModified listeners slow down setAttribute calls within
   1.235 +              // the document, see bug 395496
   1.236 +              if (document instanceof Components.interfaces.nsIDOMXULDocument) {
   1.237 +                document.addBroadcastListenerFor(val, this, "value");
   1.238 +                document.addBroadcastListenerFor(val, this, "label");
   1.239 +                document.addBroadcastListenerFor(val, this, "image");
   1.240 +                document.addBroadcastListenerFor(val, this, "description");
   1.241 +              }
   1.242 +              else
   1.243 +                val.addEventListener("DOMAttrModified", this, false);
   1.244 +            }
   1.245 +            else {
   1.246 +              this.removeAttribute('value');
   1.247 +              this.removeAttribute('image');
   1.248 +              this.removeAttribute('label');
   1.249 +              this.removeAttribute('description');
   1.250 +            }
   1.251 +
   1.252 +            var event = document.createEvent("Events");
   1.253 +            event.initEvent("select", true, true);
   1.254 +            this.dispatchEvent(event);
   1.255 +
   1.256 +            var event = document.createEvent("Events");
   1.257 +            event.initEvent("ValueChange", true, true);
   1.258 +            this.dispatchEvent(event);
   1.259 +
   1.260 +            return val;
   1.261 +          ]]>
   1.262 +        </setter>
   1.263 +      </property>
   1.264 +
   1.265 +      <method name="handleEvent">
   1.266 +        <parameter name="aEvent"/>
   1.267 +        <body>
   1.268 +          <![CDATA[
   1.269 +            if (aEvent.type == "DOMAttrModified" &&
   1.270 +                aEvent.target == this.mSelectedInternal) {
   1.271 +              var attrName = aEvent.attrName;
   1.272 +              switch (attrName) {
   1.273 +                case "value":
   1.274 +                case "label":
   1.275 +                case "image":
   1.276 +                case "description":
   1.277 +                  this.setAttribute(attrName, aEvent.newValue);
   1.278 +              }
   1.279 +            }
   1.280 +          ]]>
   1.281 +        </body>
   1.282 +      </method>
   1.283 +
   1.284 +      <method name="getIndexOfItem">
   1.285 +        <parameter name="item"/>
   1.286 +        <body>
   1.287 +        <![CDATA[
   1.288 +          var popup = this.menupopup;
   1.289 +          if (popup) {
   1.290 +            var children = popup.childNodes;
   1.291 +            var i = children.length;
   1.292 +            while (i--)
   1.293 +              if (children[i] == item)
   1.294 +                return i;
   1.295 +          }
   1.296 +          return -1;
   1.297 +        ]]>
   1.298 +        </body>
   1.299 +      </method>
   1.300 +
   1.301 +      <method name="getItemAtIndex">
   1.302 +        <parameter name="index"/>
   1.303 +        <body>
   1.304 +        <![CDATA[
   1.305 +          var popup = this.menupopup;
   1.306 +          if (popup) {
   1.307 +            var children = popup.childNodes;
   1.308 +            if (index >= 0 && index < children.length)
   1.309 +              return children[index];
   1.310 +          }
   1.311 +          return null;
   1.312 +        ]]>
   1.313 +        </body>
   1.314 +      </method>
   1.315 +
   1.316 +      <method name="appendItem">
   1.317 +        <parameter name="label"/>
   1.318 +        <parameter name="value"/>
   1.319 +        <parameter name="description"/>
   1.320 +        <body>
   1.321 +        <![CDATA[
   1.322 +          const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
   1.323 +          var popup = this.menupopup ||
   1.324 +                      this.appendChild(document.createElementNS(XULNS, "menupopup"));
   1.325 +          var item = document.createElementNS(XULNS, "menuitem");
   1.326 +          item.setAttribute("label", label);
   1.327 +          item.setAttribute("value", value);
   1.328 +          if (description)
   1.329 +            item.setAttribute("description", description);
   1.330 +
   1.331 +          popup.appendChild(item);
   1.332 +          return item;
   1.333 +        ]]>
   1.334 +        </body>
   1.335 +      </method>
   1.336 +
   1.337 +      <method name="insertItemAt">
   1.338 +        <parameter name="index"/>
   1.339 +        <parameter name="label"/>
   1.340 +        <parameter name="value"/>
   1.341 +        <parameter name="description"/>
   1.342 +        <body>
   1.343 +        <![CDATA[
   1.344 +          const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
   1.345 +          var popup = this.menupopup ||
   1.346 +                      this.appendChild(document.createElementNS(XULNS, "menupopup"));
   1.347 +          var item = document.createElementNS(XULNS, "menuitem");
   1.348 +          item.setAttribute("label", label);
   1.349 +          item.setAttribute("value", value);
   1.350 +          if (description)
   1.351 +            item.setAttribute("description", description);
   1.352 +
   1.353 +          if (index >= 0 && index < popup.childNodes.length)
   1.354 +            popup.insertBefore(item, popup.childNodes[index]);
   1.355 +          else
   1.356 +            popup.appendChild(item);
   1.357 +          return item;
   1.358 +        ]]>
   1.359 +        </body>
   1.360 +      </method>
   1.361 +
   1.362 +      <method name="removeItemAt">
   1.363 +        <parameter name="index"/>
   1.364 +        <body>
   1.365 +        <![CDATA[
   1.366 +          var popup = this.menupopup;
   1.367 +          if (popup && 0 <= index && index < popup.childNodes.length) {
   1.368 +            var remove = popup.childNodes[index];
   1.369 +            popup.removeChild(remove);
   1.370 +            return remove;
   1.371 +          }
   1.372 +          return null;
   1.373 +        ]]>
   1.374 +        </body>
   1.375 +      </method>
   1.376 +
   1.377 +      <method name="removeAllItems">
   1.378 +        <body>
   1.379 +        <![CDATA[
   1.380 +          this.selectedItem = null;
   1.381 +          var popup = this.menupopup;
   1.382 +          if (popup)
   1.383 +            this.removeChild(popup);
   1.384 +        ]]>
   1.385 +        </body>
   1.386 +      </method>
   1.387 +
   1.388 +      <destructor>
   1.389 +        <![CDATA[
   1.390 +          if (this.mSelectedInternal) {
   1.391 +            if (document instanceof Components.interfaces.nsIDOMXULDocument) {
   1.392 +              document.removeBroadcastListenerFor(this.mSelectedInternal, this, "value");
   1.393 +              document.removeBroadcastListenerFor(this.mSelectedInternal, this, "label");
   1.394 +              document.removeBroadcastListenerFor(this.mSelectedInternal, this, "image");
   1.395 +              document.removeBroadcastListenerFor(this.mSelectedInternal, this, "description");
   1.396 +            }
   1.397 +            else
   1.398 +              this.mSelectedInternal.removeEventListener("DOMAttrModified", this, false);
   1.399 +          }
   1.400 +        ]]>
   1.401 +      </destructor>
   1.402 +    </implementation>
   1.403 +  </binding>
   1.404 +
   1.405 +  <binding id="menulist-editable" extends="chrome://global/content/bindings/menulist.xml#menulist">
   1.406 +    <content sizetopopup="pref">
   1.407 +      <xul:hbox class="menulist-editable-box textbox-input-box" xbl:inherits="context,disabled,readonly,focused" flex="1">
   1.408 +        <html:input class="menulist-editable-input" anonid="input" allowevents="true"
   1.409 +                    xbl:inherits="value=label,value,disabled,tabindex,readonly,placeholder"/>
   1.410 +      </xul:hbox>
   1.411 +      <xul:dropmarker class="menulist-dropmarker" type="menu"
   1.412 +                      xbl:inherits="open,disabled,parentfocused=focused"/>
   1.413 +      <children includes="menupopup"/>
   1.414 +    </content>
   1.415 +
   1.416 +    <implementation>
   1.417 +      <method name="_selectInputFieldValueInList">
   1.418 +        <body>
   1.419 +        <![CDATA[
   1.420 +          if (this.hasAttribute("disableautoselect"))
   1.421 +            return;
   1.422 +
   1.423 +          // Find and select the menuitem that matches inputField's "value"
   1.424 +          var arr = null;
   1.425 +          var popup = this.menupopup;
   1.426 +
   1.427 +          if (popup)
   1.428 +            arr = popup.getElementsByAttribute('label', this.inputField.value);
   1.429 +
   1.430 +          this.setSelectionInternal(arr ? arr.item(0) : null);
   1.431 +        ]]>
   1.432 +        </body>
   1.433 +      </method>
   1.434 +
   1.435 +      <method name="setSelectionInternal">
   1.436 +        <parameter name="val"/>
   1.437 +        <body>
   1.438 +          <![CDATA[
   1.439 +            // This is called internally to set selected item
   1.440 +            //  without triggering infinite loop
   1.441 +            //  when using selectedItem's setter
   1.442 +            if (this.mSelectedInternal == val)
   1.443 +              return val;
   1.444 +
   1.445 +            if (this.mSelectedInternal)
   1.446 +              this.mSelectedInternal.removeAttribute('selected');
   1.447 +
   1.448 +            this.mSelectedInternal = val;
   1.449 +
   1.450 +            if (val)
   1.451 +              val.setAttribute('selected', 'true');
   1.452 +
   1.453 +            //Do NOT change the "value", which is owned by inputField
   1.454 +            return val;
   1.455 +          ]]>
   1.456 +        </body>
   1.457 +      </method>
   1.458 +
   1.459 +      <property name="inputField" readonly="true">
   1.460 +        <getter><![CDATA[
   1.461 +          if (!this.mInputField)
   1.462 +            this.mInputField = document.getAnonymousElementByAttribute(this, "anonid", "input");
   1.463 +          return this.mInputField;
   1.464 +        ]]></getter>
   1.465 +      </property>
   1.466 +
   1.467 +      <property name="label"      onset="this.inputField.value = val; return val;"
   1.468 +                                  onget="return this.inputField.value;"/>
   1.469 +
   1.470 +      <property name="value"      onget="return this.inputField.value;">
   1.471 +        <setter>
   1.472 +        <![CDATA[
   1.473 +          // Override menulist's value setter to refer to the inputField's value
   1.474 +          // (Allows using "menulist.value" instead of "menulist.inputField.value")
   1.475 +          this.inputField.value = val;
   1.476 +          this.setAttribute('value', val);
   1.477 +          this.setAttribute('label', val);
   1.478 +          this._selectInputFieldValueInList();
   1.479 +          return val;
   1.480 +        ]]>
   1.481 +        </setter>
   1.482 +      </property>
   1.483 +
   1.484 +      <property name="selectedItem">
   1.485 +        <getter>
   1.486 +          <![CDATA[
   1.487 +            // Make sure internally-selected item
   1.488 +            //  is in sync with inputField.value
   1.489 +            this._selectInputFieldValueInList();
   1.490 +            return this.mSelectedInternal;
   1.491 +          ]]>
   1.492 +        </getter>
   1.493 +        <setter>
   1.494 +          <![CDATA[
   1.495 +            var oldval = this.mSelectedInternal;
   1.496 +            if (oldval == val)
   1.497 +              return val;
   1.498 +
   1.499 +            if (val && !this.contains(val))
   1.500 +              return val;
   1.501 +
   1.502 +            // This doesn't touch inputField.value or "value" and "label" attributes
   1.503 +            this.setSelectionInternal(val);
   1.504 +            if (val) {
   1.505 +              // Editable menulist uses "label" as its "value"
   1.506 +              var label = val.getAttribute('label');
   1.507 +              this.inputField.value = label;
   1.508 +              this.setAttribute('value', label);
   1.509 +              this.setAttribute('label', label);
   1.510 +            }
   1.511 +            else {
   1.512 +              this.inputField.value = "";
   1.513 +              this.removeAttribute('value');
   1.514 +              this.removeAttribute('label');
   1.515 +            }
   1.516 +
   1.517 +            var event = document.createEvent("Events");
   1.518 +            event.initEvent("select", true, true);
   1.519 +            this.dispatchEvent(event);
   1.520 +
   1.521 +            var event = document.createEvent("Events");
   1.522 +            event.initEvent("ValueChange", true, true);
   1.523 +            this.dispatchEvent(event);
   1.524 +
   1.525 +            return val;
   1.526 +          ]]>
   1.527 +        </setter>
   1.528 +      </property>
   1.529 +      <property name="disableautoselect"
   1.530 +                onset="if (val) this.setAttribute('disableautoselect','true');
   1.531 +                       else this.removeAttribute('disableautoselect'); return val;"
   1.532 +                onget="return this.hasAttribute('disableautoselect');"/>
   1.533 +
   1.534 +      <property name="editor" readonly="true">
   1.535 +        <getter><![CDATA[
   1.536 +          const nsIDOMNSEditableElement = Components.interfaces.nsIDOMNSEditableElement;
   1.537 +          return this.inputField.QueryInterface(nsIDOMNSEditableElement).editor;
   1.538 +        ]]></getter>
   1.539 +      </property>
   1.540 +
   1.541 +      <property name="readOnly"   onset="this.inputField.readOnly = val;
   1.542 +                                         if (val) this.setAttribute('readonly', 'true');
   1.543 +                                         else this.removeAttribute('readonly'); return val;"
   1.544 +                                  onget="return this.inputField.readOnly;"/>
   1.545 +
   1.546 +      <method name="select">
   1.547 +        <body>
   1.548 +          this.inputField.select();
   1.549 +        </body>
   1.550 +      </method>
   1.551 +    </implementation>
   1.552 +
   1.553 +    <handlers>
   1.554 +      <handler event="focus" phase="capturing">
   1.555 +        <![CDATA[
   1.556 +          this.setAttribute('focused','true');
   1.557 +        ]]>
   1.558 +      </handler>
   1.559 +
   1.560 +      <handler event="blur" phase="capturing">
   1.561 +        <![CDATA[
   1.562 +          this.removeAttribute('focused');
   1.563 +        ]]>
   1.564 +      </handler>
   1.565 +
   1.566 +      <handler event="popupshowing">
   1.567 +        <![CDATA[
   1.568 +          // editable menulists elements aren't in the focus order,
   1.569 +          // so when the popup opens we need to force the focus to the inputField
   1.570 +          if (event.target.parentNode == this) {
   1.571 +            if (document.commandDispatcher.focusedElement != this.inputField)
   1.572 +              this.inputField.focus();
   1.573 +
   1.574 +            this.menuBoxObject.activeChild = null;
   1.575 +            if (this.selectedItem)
   1.576 +              // Not ready for auto-setting the active child in hierarchies yet.
   1.577 +              // For now, only do this when the outermost menupopup opens.
   1.578 +              this.menuBoxObject.activeChild = this.mSelectedInternal;
   1.579 +          }
   1.580 +        ]]>
   1.581 +      </handler>
   1.582 +
   1.583 +      <handler event="keypress">
   1.584 +        <![CDATA[
   1.585 +          // open popup if key is up arrow, down arrow, or F4
   1.586 +          if (!event.ctrlKey && !event.shiftKey) {
   1.587 +            if (event.keyCode == KeyEvent.DOM_VK_UP ||
   1.588 +                event.keyCode == KeyEvent.DOM_VK_DOWN ||
   1.589 +                (event.keyCode == KeyEvent.DOM_VK_F4 && !event.altKey)) {
   1.590 +              event.preventDefault();
   1.591 +              this.open = true;
   1.592 +            }
   1.593 +          }
   1.594 +        ]]>
   1.595 +      </handler>
   1.596 +    </handlers>
   1.597 +  </binding>
   1.598 +
   1.599 +  <binding id="menulist-compact" display="xul:menu"
   1.600 +           extends="chrome://global/content/bindings/menulist.xml#menulist">
   1.601 +    <content sizetopopup="false">
   1.602 +      <xul:dropmarker class="menulist-dropmarker" type="menu" xbl:inherits="disabled,open"/>
   1.603 +      <xul:image class="menulist-icon" xbl:inherits="src=image,src"/>
   1.604 +      <xul:label class="menulist-label" xbl:inherits="value=label,crop,accesskey" crop="right" flex="1"/>
   1.605 +      <children includes="menupopup"/>
   1.606 +    </content>
   1.607 +  </binding>
   1.608 +
   1.609 +  <binding id="menulist-description" display="xul:menu"
   1.610 +           extends="chrome://global/content/bindings/menulist.xml#menulist">
   1.611 +    <content sizetopopup="pref">
   1.612 +      <xul:hbox class="menulist-label-box" flex="1">
   1.613 +        <xul:image class="menulist-icon" xbl:inherits="src=image,src"/>
   1.614 +        <xul:label class="menulist-label" xbl:inherits="value=label,crop,accesskey" crop="right" flex="1"/>
   1.615 +        <xul:label class="menulist-label menulist-description" xbl:inherits="value=description" crop="right" flex="10000"/>
   1.616 +      </xul:hbox>
   1.617 +      <xul:dropmarker class="menulist-dropmarker" type="menu" xbl:inherits="disabled,open"/>
   1.618 +      <children includes="menupopup"/>
   1.619 +    </content>
   1.620 +  </binding>
   1.621 +</bindings>

mercurial