toolkit/content/widgets/menulist.xml

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 - License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
michael@0 5
michael@0 6
michael@0 7 <bindings id="menulistBindings"
michael@0 8 xmlns="http://www.mozilla.org/xbl"
michael@0 9 xmlns:html="http://www.w3.org/1999/xhtml"
michael@0 10 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 11 xmlns:xbl="http://www.mozilla.org/xbl">
michael@0 12
michael@0 13 <binding id="menulist-base" extends="chrome://global/content/bindings/general.xml#basecontrol">
michael@0 14 <resources>
michael@0 15 <stylesheet src="chrome://global/content/menulist.css"/>
michael@0 16 <stylesheet src="chrome://global/skin/menulist.css"/>
michael@0 17 </resources>
michael@0 18 </binding>
michael@0 19
michael@0 20 <binding id="menulist" display="xul:menu" role="xul:menulist"
michael@0 21 extends="chrome://global/content/bindings/menulist.xml#menulist-base">
michael@0 22 <content sizetopopup="pref">
michael@0 23 <xul:hbox class="menulist-label-box" flex="1">
michael@0 24 <xul:image class="menulist-icon" xbl:inherits="src=image,src"/>
michael@0 25 <xul:label class="menulist-label" xbl:inherits="value=label,crop,accesskey" crop="right" flex="1"/>
michael@0 26 </xul:hbox>
michael@0 27 <xul:dropmarker class="menulist-dropmarker" type="menu" xbl:inherits="disabled,open"/>
michael@0 28 <children includes="menupopup"/>
michael@0 29 </content>
michael@0 30
michael@0 31 <handlers>
michael@0 32 <handler event="command" phase="capturing"
michael@0 33 action="if (event.target.parentNode.parentNode == this) this.selectedItem = event.target;"/>
michael@0 34
michael@0 35 <handler event="popupshowing">
michael@0 36 <![CDATA[
michael@0 37 if (event.target.parentNode == this) {
michael@0 38 this.menuBoxObject.activeChild = null;
michael@0 39 if (this.selectedItem)
michael@0 40 // Not ready for auto-setting the active child in hierarchies yet.
michael@0 41 // For now, only do this when the outermost menupopup opens.
michael@0 42 this.menuBoxObject.activeChild = this.mSelectedInternal;
michael@0 43 }
michael@0 44 ]]>
michael@0 45 </handler>
michael@0 46
michael@0 47 <handler event="keypress" modifiers="shift any" group="system">
michael@0 48 <![CDATA[
michael@0 49 if (!event.defaultPrevented &&
michael@0 50 (event.keyCode == KeyEvent.DOM_VK_UP ||
michael@0 51 event.keyCode == KeyEvent.DOM_VK_DOWN ||
michael@0 52 event.keyCode == KeyEvent.DOM_VK_PAGE_UP ||
michael@0 53 event.keyCode == KeyEvent.DOM_VK_PAGE_DOWN ||
michael@0 54 event.keyCode == KeyEvent.DOM_VK_HOME ||
michael@0 55 event.keyCode == KeyEvent.DOM_VK_END ||
michael@0 56 event.keyCode == KeyEvent.DOM_VK_BACK_SPACE ||
michael@0 57 event.charCode > 0)) {
michael@0 58 // Moving relative to an item: start from the currently selected item
michael@0 59 this.menuBoxObject.activeChild = this.mSelectedInternal;
michael@0 60 if (this.menuBoxObject.handleKeyPress(event)) {
michael@0 61 this.menuBoxObject.activeChild.doCommand();
michael@0 62 event.preventDefault();
michael@0 63 }
michael@0 64 }
michael@0 65 ]]>
michael@0 66 </handler>
michael@0 67 </handlers>
michael@0 68
michael@0 69 <implementation implements="nsIDOMXULMenuListElement, nsIDOMEventListener">
michael@0 70 <constructor>
michael@0 71 this.mInputField = null;
michael@0 72 this.mSelectedInternal = null;
michael@0 73 this.menuBoxObject = this.boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject);
michael@0 74 this.setInitialSelection();
michael@0 75 </constructor>
michael@0 76
michael@0 77 <method name="setInitialSelection">
michael@0 78 <body>
michael@0 79 <![CDATA[
michael@0 80 var popup = this.menupopup;
michael@0 81 if (popup) {
michael@0 82 var arr = popup.getElementsByAttribute('selected', 'true');
michael@0 83
michael@0 84 var editable = this.editable;
michael@0 85 var value = this.value;
michael@0 86 if (!arr.item(0) && value)
michael@0 87 arr = popup.getElementsByAttribute(editable ? 'label' : 'value', value);
michael@0 88
michael@0 89 if (arr.item(0))
michael@0 90 this.selectedItem = arr[0];
michael@0 91 else if (!editable)
michael@0 92 this.selectedIndex = 0;
michael@0 93 }
michael@0 94 ]]>
michael@0 95 </body>
michael@0 96 </method>
michael@0 97
michael@0 98 <property name="value" onget="return this.getAttribute('value');">
michael@0 99 <setter>
michael@0 100 <![CDATA[
michael@0 101 // if the new value is null, we still need to remove the old value
michael@0 102 if (val == null)
michael@0 103 return this.selectedItem = val;
michael@0 104
michael@0 105 var arr = null;
michael@0 106 var popup = this.menupopup;
michael@0 107 if (popup)
michael@0 108 arr = popup.getElementsByAttribute('value', val);
michael@0 109
michael@0 110 if (arr && arr.item(0))
michael@0 111 this.selectedItem = arr[0];
michael@0 112 else {
michael@0 113 this.selectedItem = null;
michael@0 114 this.setAttribute('value', val);
michael@0 115 }
michael@0 116
michael@0 117 return val;
michael@0 118 ]]>
michael@0 119 </setter>
michael@0 120 </property>
michael@0 121
michael@0 122 <property name="inputField" readonly="true" onget="return null;"/>
michael@0 123
michael@0 124 <property name="crop" onset="this.setAttribute('crop',val); return val;"
michael@0 125 onget="return this.getAttribute('crop');"/>
michael@0 126 <property name="image" onset="this.setAttribute('image',val); return val;"
michael@0 127 onget="return this.getAttribute('image');"/>
michael@0 128 <property name="label" readonly="true" onget="return this.getAttribute('label');"/>
michael@0 129 <property name="description" onset="this.setAttribute('description',val); return val;"
michael@0 130 onget="return this.getAttribute('description');"/>
michael@0 131 <property name="editable" onset="this.setAttribute('editable',val); return val;"
michael@0 132 onget="return this.getAttribute('editable') == 'true';"/>
michael@0 133
michael@0 134 <property name="open" onset="this.menuBoxObject.openMenu(val);
michael@0 135 return val;"
michael@0 136 onget="return this.hasAttribute('open');"/>
michael@0 137
michael@0 138 <property name="itemCount" readonly="true"
michael@0 139 onget="return this.menupopup ? this.menupopup.childNodes.length : 0"/>
michael@0 140
michael@0 141 <property name="menupopup" readonly="true">
michael@0 142 <getter>
michael@0 143 <![CDATA[
michael@0 144 var popup = this.firstChild;
michael@0 145 while (popup && popup.localName != "menupopup")
michael@0 146 popup = popup.nextSibling;
michael@0 147 return popup;
michael@0 148 ]]>
michael@0 149 </getter>
michael@0 150 </property>
michael@0 151
michael@0 152 <method name="contains">
michael@0 153 <parameter name="item"/>
michael@0 154 <body>
michael@0 155 <![CDATA[
michael@0 156 if (!item)
michael@0 157 return false;
michael@0 158
michael@0 159 var parent = item.parentNode;
michael@0 160 return (parent && parent.parentNode == this);
michael@0 161 ]]>
michael@0 162 </body>
michael@0 163 </method>
michael@0 164
michael@0 165 <property name="selectedIndex">
michael@0 166 <getter>
michael@0 167 <![CDATA[
michael@0 168 // Quick and dirty. We won't deal with hierarchical menulists yet.
michael@0 169 if (!this.selectedItem ||
michael@0 170 !this.mSelectedInternal.parentNode ||
michael@0 171 this.mSelectedInternal.parentNode.parentNode != this)
michael@0 172 return -1;
michael@0 173
michael@0 174 var children = this.mSelectedInternal.parentNode.childNodes;
michael@0 175 var i = children.length;
michael@0 176 while (i--)
michael@0 177 if (children[i] == this.mSelectedInternal)
michael@0 178 break;
michael@0 179
michael@0 180 return i;
michael@0 181 ]]>
michael@0 182 </getter>
michael@0 183 <setter>
michael@0 184 <![CDATA[
michael@0 185 var popup = this.menupopup;
michael@0 186 if (popup && 0 <= val) {
michael@0 187 if (val < popup.childNodes.length)
michael@0 188 this.selectedItem = popup.childNodes[val];
michael@0 189 }
michael@0 190 else
michael@0 191 this.selectedItem = null;
michael@0 192 return val;
michael@0 193 ]]>
michael@0 194 </setter>
michael@0 195 </property>
michael@0 196
michael@0 197 <property name="selectedItem">
michael@0 198 <getter>
michael@0 199 <![CDATA[
michael@0 200 return this.mSelectedInternal;
michael@0 201 ]]>
michael@0 202 </getter>
michael@0 203 <setter>
michael@0 204 <![CDATA[
michael@0 205 var oldval = this.mSelectedInternal;
michael@0 206 if (oldval == val)
michael@0 207 return val;
michael@0 208
michael@0 209 if (val && !this.contains(val))
michael@0 210 return val;
michael@0 211
michael@0 212 if (oldval) {
michael@0 213 oldval.removeAttribute('selected');
michael@0 214 if (document instanceof Components.interfaces.nsIDOMXULDocument) {
michael@0 215 document.removeBroadcastListenerFor(oldval, this, "value");
michael@0 216 document.removeBroadcastListenerFor(oldval, this, "label");
michael@0 217 document.removeBroadcastListenerFor(oldval, this, "image");
michael@0 218 document.removeBroadcastListenerFor(oldval, this, "description");
michael@0 219 }
michael@0 220 else
michael@0 221 oldval.removeEventListener("DOMAttrModified", this, false);
michael@0 222 }
michael@0 223
michael@0 224 this.mSelectedInternal = val;
michael@0 225 if (val) {
michael@0 226 val.setAttribute('selected', 'true');
michael@0 227 this.setAttribute('value', val.getAttribute('value'));
michael@0 228 this.setAttribute('image', val.getAttribute('image'));
michael@0 229 this.setAttribute('label', val.getAttribute('label'));
michael@0 230 this.setAttribute('description', val.getAttribute('description'));
michael@0 231 // DOMAttrModified listeners slow down setAttribute calls within
michael@0 232 // the document, see bug 395496
michael@0 233 if (document instanceof Components.interfaces.nsIDOMXULDocument) {
michael@0 234 document.addBroadcastListenerFor(val, this, "value");
michael@0 235 document.addBroadcastListenerFor(val, this, "label");
michael@0 236 document.addBroadcastListenerFor(val, this, "image");
michael@0 237 document.addBroadcastListenerFor(val, this, "description");
michael@0 238 }
michael@0 239 else
michael@0 240 val.addEventListener("DOMAttrModified", this, false);
michael@0 241 }
michael@0 242 else {
michael@0 243 this.removeAttribute('value');
michael@0 244 this.removeAttribute('image');
michael@0 245 this.removeAttribute('label');
michael@0 246 this.removeAttribute('description');
michael@0 247 }
michael@0 248
michael@0 249 var event = document.createEvent("Events");
michael@0 250 event.initEvent("select", true, true);
michael@0 251 this.dispatchEvent(event);
michael@0 252
michael@0 253 var event = document.createEvent("Events");
michael@0 254 event.initEvent("ValueChange", true, true);
michael@0 255 this.dispatchEvent(event);
michael@0 256
michael@0 257 return val;
michael@0 258 ]]>
michael@0 259 </setter>
michael@0 260 </property>
michael@0 261
michael@0 262 <method name="handleEvent">
michael@0 263 <parameter name="aEvent"/>
michael@0 264 <body>
michael@0 265 <![CDATA[
michael@0 266 if (aEvent.type == "DOMAttrModified" &&
michael@0 267 aEvent.target == this.mSelectedInternal) {
michael@0 268 var attrName = aEvent.attrName;
michael@0 269 switch (attrName) {
michael@0 270 case "value":
michael@0 271 case "label":
michael@0 272 case "image":
michael@0 273 case "description":
michael@0 274 this.setAttribute(attrName, aEvent.newValue);
michael@0 275 }
michael@0 276 }
michael@0 277 ]]>
michael@0 278 </body>
michael@0 279 </method>
michael@0 280
michael@0 281 <method name="getIndexOfItem">
michael@0 282 <parameter name="item"/>
michael@0 283 <body>
michael@0 284 <![CDATA[
michael@0 285 var popup = this.menupopup;
michael@0 286 if (popup) {
michael@0 287 var children = popup.childNodes;
michael@0 288 var i = children.length;
michael@0 289 while (i--)
michael@0 290 if (children[i] == item)
michael@0 291 return i;
michael@0 292 }
michael@0 293 return -1;
michael@0 294 ]]>
michael@0 295 </body>
michael@0 296 </method>
michael@0 297
michael@0 298 <method name="getItemAtIndex">
michael@0 299 <parameter name="index"/>
michael@0 300 <body>
michael@0 301 <![CDATA[
michael@0 302 var popup = this.menupopup;
michael@0 303 if (popup) {
michael@0 304 var children = popup.childNodes;
michael@0 305 if (index >= 0 && index < children.length)
michael@0 306 return children[index];
michael@0 307 }
michael@0 308 return null;
michael@0 309 ]]>
michael@0 310 </body>
michael@0 311 </method>
michael@0 312
michael@0 313 <method name="appendItem">
michael@0 314 <parameter name="label"/>
michael@0 315 <parameter name="value"/>
michael@0 316 <parameter name="description"/>
michael@0 317 <body>
michael@0 318 <![CDATA[
michael@0 319 const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
michael@0 320 var popup = this.menupopup ||
michael@0 321 this.appendChild(document.createElementNS(XULNS, "menupopup"));
michael@0 322 var item = document.createElementNS(XULNS, "menuitem");
michael@0 323 item.setAttribute("label", label);
michael@0 324 item.setAttribute("value", value);
michael@0 325 if (description)
michael@0 326 item.setAttribute("description", description);
michael@0 327
michael@0 328 popup.appendChild(item);
michael@0 329 return item;
michael@0 330 ]]>
michael@0 331 </body>
michael@0 332 </method>
michael@0 333
michael@0 334 <method name="insertItemAt">
michael@0 335 <parameter name="index"/>
michael@0 336 <parameter name="label"/>
michael@0 337 <parameter name="value"/>
michael@0 338 <parameter name="description"/>
michael@0 339 <body>
michael@0 340 <![CDATA[
michael@0 341 const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
michael@0 342 var popup = this.menupopup ||
michael@0 343 this.appendChild(document.createElementNS(XULNS, "menupopup"));
michael@0 344 var item = document.createElementNS(XULNS, "menuitem");
michael@0 345 item.setAttribute("label", label);
michael@0 346 item.setAttribute("value", value);
michael@0 347 if (description)
michael@0 348 item.setAttribute("description", description);
michael@0 349
michael@0 350 if (index >= 0 && index < popup.childNodes.length)
michael@0 351 popup.insertBefore(item, popup.childNodes[index]);
michael@0 352 else
michael@0 353 popup.appendChild(item);
michael@0 354 return item;
michael@0 355 ]]>
michael@0 356 </body>
michael@0 357 </method>
michael@0 358
michael@0 359 <method name="removeItemAt">
michael@0 360 <parameter name="index"/>
michael@0 361 <body>
michael@0 362 <![CDATA[
michael@0 363 var popup = this.menupopup;
michael@0 364 if (popup && 0 <= index && index < popup.childNodes.length) {
michael@0 365 var remove = popup.childNodes[index];
michael@0 366 popup.removeChild(remove);
michael@0 367 return remove;
michael@0 368 }
michael@0 369 return null;
michael@0 370 ]]>
michael@0 371 </body>
michael@0 372 </method>
michael@0 373
michael@0 374 <method name="removeAllItems">
michael@0 375 <body>
michael@0 376 <![CDATA[
michael@0 377 this.selectedItem = null;
michael@0 378 var popup = this.menupopup;
michael@0 379 if (popup)
michael@0 380 this.removeChild(popup);
michael@0 381 ]]>
michael@0 382 </body>
michael@0 383 </method>
michael@0 384
michael@0 385 <destructor>
michael@0 386 <![CDATA[
michael@0 387 if (this.mSelectedInternal) {
michael@0 388 if (document instanceof Components.interfaces.nsIDOMXULDocument) {
michael@0 389 document.removeBroadcastListenerFor(this.mSelectedInternal, this, "value");
michael@0 390 document.removeBroadcastListenerFor(this.mSelectedInternal, this, "label");
michael@0 391 document.removeBroadcastListenerFor(this.mSelectedInternal, this, "image");
michael@0 392 document.removeBroadcastListenerFor(this.mSelectedInternal, this, "description");
michael@0 393 }
michael@0 394 else
michael@0 395 this.mSelectedInternal.removeEventListener("DOMAttrModified", this, false);
michael@0 396 }
michael@0 397 ]]>
michael@0 398 </destructor>
michael@0 399 </implementation>
michael@0 400 </binding>
michael@0 401
michael@0 402 <binding id="menulist-editable" extends="chrome://global/content/bindings/menulist.xml#menulist">
michael@0 403 <content sizetopopup="pref">
michael@0 404 <xul:hbox class="menulist-editable-box textbox-input-box" xbl:inherits="context,disabled,readonly,focused" flex="1">
michael@0 405 <html:input class="menulist-editable-input" anonid="input" allowevents="true"
michael@0 406 xbl:inherits="value=label,value,disabled,tabindex,readonly,placeholder"/>
michael@0 407 </xul:hbox>
michael@0 408 <xul:dropmarker class="menulist-dropmarker" type="menu"
michael@0 409 xbl:inherits="open,disabled,parentfocused=focused"/>
michael@0 410 <children includes="menupopup"/>
michael@0 411 </content>
michael@0 412
michael@0 413 <implementation>
michael@0 414 <method name="_selectInputFieldValueInList">
michael@0 415 <body>
michael@0 416 <![CDATA[
michael@0 417 if (this.hasAttribute("disableautoselect"))
michael@0 418 return;
michael@0 419
michael@0 420 // Find and select the menuitem that matches inputField's "value"
michael@0 421 var arr = null;
michael@0 422 var popup = this.menupopup;
michael@0 423
michael@0 424 if (popup)
michael@0 425 arr = popup.getElementsByAttribute('label', this.inputField.value);
michael@0 426
michael@0 427 this.setSelectionInternal(arr ? arr.item(0) : null);
michael@0 428 ]]>
michael@0 429 </body>
michael@0 430 </method>
michael@0 431
michael@0 432 <method name="setSelectionInternal">
michael@0 433 <parameter name="val"/>
michael@0 434 <body>
michael@0 435 <![CDATA[
michael@0 436 // This is called internally to set selected item
michael@0 437 // without triggering infinite loop
michael@0 438 // when using selectedItem's setter
michael@0 439 if (this.mSelectedInternal == val)
michael@0 440 return val;
michael@0 441
michael@0 442 if (this.mSelectedInternal)
michael@0 443 this.mSelectedInternal.removeAttribute('selected');
michael@0 444
michael@0 445 this.mSelectedInternal = val;
michael@0 446
michael@0 447 if (val)
michael@0 448 val.setAttribute('selected', 'true');
michael@0 449
michael@0 450 //Do NOT change the "value", which is owned by inputField
michael@0 451 return val;
michael@0 452 ]]>
michael@0 453 </body>
michael@0 454 </method>
michael@0 455
michael@0 456 <property name="inputField" readonly="true">
michael@0 457 <getter><![CDATA[
michael@0 458 if (!this.mInputField)
michael@0 459 this.mInputField = document.getAnonymousElementByAttribute(this, "anonid", "input");
michael@0 460 return this.mInputField;
michael@0 461 ]]></getter>
michael@0 462 </property>
michael@0 463
michael@0 464 <property name="label" onset="this.inputField.value = val; return val;"
michael@0 465 onget="return this.inputField.value;"/>
michael@0 466
michael@0 467 <property name="value" onget="return this.inputField.value;">
michael@0 468 <setter>
michael@0 469 <![CDATA[
michael@0 470 // Override menulist's value setter to refer to the inputField's value
michael@0 471 // (Allows using "menulist.value" instead of "menulist.inputField.value")
michael@0 472 this.inputField.value = val;
michael@0 473 this.setAttribute('value', val);
michael@0 474 this.setAttribute('label', val);
michael@0 475 this._selectInputFieldValueInList();
michael@0 476 return val;
michael@0 477 ]]>
michael@0 478 </setter>
michael@0 479 </property>
michael@0 480
michael@0 481 <property name="selectedItem">
michael@0 482 <getter>
michael@0 483 <![CDATA[
michael@0 484 // Make sure internally-selected item
michael@0 485 // is in sync with inputField.value
michael@0 486 this._selectInputFieldValueInList();
michael@0 487 return this.mSelectedInternal;
michael@0 488 ]]>
michael@0 489 </getter>
michael@0 490 <setter>
michael@0 491 <![CDATA[
michael@0 492 var oldval = this.mSelectedInternal;
michael@0 493 if (oldval == val)
michael@0 494 return val;
michael@0 495
michael@0 496 if (val && !this.contains(val))
michael@0 497 return val;
michael@0 498
michael@0 499 // This doesn't touch inputField.value or "value" and "label" attributes
michael@0 500 this.setSelectionInternal(val);
michael@0 501 if (val) {
michael@0 502 // Editable menulist uses "label" as its "value"
michael@0 503 var label = val.getAttribute('label');
michael@0 504 this.inputField.value = label;
michael@0 505 this.setAttribute('value', label);
michael@0 506 this.setAttribute('label', label);
michael@0 507 }
michael@0 508 else {
michael@0 509 this.inputField.value = "";
michael@0 510 this.removeAttribute('value');
michael@0 511 this.removeAttribute('label');
michael@0 512 }
michael@0 513
michael@0 514 var event = document.createEvent("Events");
michael@0 515 event.initEvent("select", true, true);
michael@0 516 this.dispatchEvent(event);
michael@0 517
michael@0 518 var event = document.createEvent("Events");
michael@0 519 event.initEvent("ValueChange", true, true);
michael@0 520 this.dispatchEvent(event);
michael@0 521
michael@0 522 return val;
michael@0 523 ]]>
michael@0 524 </setter>
michael@0 525 </property>
michael@0 526 <property name="disableautoselect"
michael@0 527 onset="if (val) this.setAttribute('disableautoselect','true');
michael@0 528 else this.removeAttribute('disableautoselect'); return val;"
michael@0 529 onget="return this.hasAttribute('disableautoselect');"/>
michael@0 530
michael@0 531 <property name="editor" readonly="true">
michael@0 532 <getter><![CDATA[
michael@0 533 const nsIDOMNSEditableElement = Components.interfaces.nsIDOMNSEditableElement;
michael@0 534 return this.inputField.QueryInterface(nsIDOMNSEditableElement).editor;
michael@0 535 ]]></getter>
michael@0 536 </property>
michael@0 537
michael@0 538 <property name="readOnly" onset="this.inputField.readOnly = val;
michael@0 539 if (val) this.setAttribute('readonly', 'true');
michael@0 540 else this.removeAttribute('readonly'); return val;"
michael@0 541 onget="return this.inputField.readOnly;"/>
michael@0 542
michael@0 543 <method name="select">
michael@0 544 <body>
michael@0 545 this.inputField.select();
michael@0 546 </body>
michael@0 547 </method>
michael@0 548 </implementation>
michael@0 549
michael@0 550 <handlers>
michael@0 551 <handler event="focus" phase="capturing">
michael@0 552 <![CDATA[
michael@0 553 this.setAttribute('focused','true');
michael@0 554 ]]>
michael@0 555 </handler>
michael@0 556
michael@0 557 <handler event="blur" phase="capturing">
michael@0 558 <![CDATA[
michael@0 559 this.removeAttribute('focused');
michael@0 560 ]]>
michael@0 561 </handler>
michael@0 562
michael@0 563 <handler event="popupshowing">
michael@0 564 <![CDATA[
michael@0 565 // editable menulists elements aren't in the focus order,
michael@0 566 // so when the popup opens we need to force the focus to the inputField
michael@0 567 if (event.target.parentNode == this) {
michael@0 568 if (document.commandDispatcher.focusedElement != this.inputField)
michael@0 569 this.inputField.focus();
michael@0 570
michael@0 571 this.menuBoxObject.activeChild = null;
michael@0 572 if (this.selectedItem)
michael@0 573 // Not ready for auto-setting the active child in hierarchies yet.
michael@0 574 // For now, only do this when the outermost menupopup opens.
michael@0 575 this.menuBoxObject.activeChild = this.mSelectedInternal;
michael@0 576 }
michael@0 577 ]]>
michael@0 578 </handler>
michael@0 579
michael@0 580 <handler event="keypress">
michael@0 581 <![CDATA[
michael@0 582 // open popup if key is up arrow, down arrow, or F4
michael@0 583 if (!event.ctrlKey && !event.shiftKey) {
michael@0 584 if (event.keyCode == KeyEvent.DOM_VK_UP ||
michael@0 585 event.keyCode == KeyEvent.DOM_VK_DOWN ||
michael@0 586 (event.keyCode == KeyEvent.DOM_VK_F4 && !event.altKey)) {
michael@0 587 event.preventDefault();
michael@0 588 this.open = true;
michael@0 589 }
michael@0 590 }
michael@0 591 ]]>
michael@0 592 </handler>
michael@0 593 </handlers>
michael@0 594 </binding>
michael@0 595
michael@0 596 <binding id="menulist-compact" display="xul:menu"
michael@0 597 extends="chrome://global/content/bindings/menulist.xml#menulist">
michael@0 598 <content sizetopopup="false">
michael@0 599 <xul:dropmarker class="menulist-dropmarker" type="menu" xbl:inherits="disabled,open"/>
michael@0 600 <xul:image class="menulist-icon" xbl:inherits="src=image,src"/>
michael@0 601 <xul:label class="menulist-label" xbl:inherits="value=label,crop,accesskey" crop="right" flex="1"/>
michael@0 602 <children includes="menupopup"/>
michael@0 603 </content>
michael@0 604 </binding>
michael@0 605
michael@0 606 <binding id="menulist-description" display="xul:menu"
michael@0 607 extends="chrome://global/content/bindings/menulist.xml#menulist">
michael@0 608 <content sizetopopup="pref">
michael@0 609 <xul:hbox class="menulist-label-box" flex="1">
michael@0 610 <xul:image class="menulist-icon" xbl:inherits="src=image,src"/>
michael@0 611 <xul:label class="menulist-label" xbl:inherits="value=label,crop,accesskey" crop="right" flex="1"/>
michael@0 612 <xul:label class="menulist-label menulist-description" xbl:inherits="value=description" crop="right" flex="10000"/>
michael@0 613 </xul:hbox>
michael@0 614 <xul:dropmarker class="menulist-dropmarker" type="menu" xbl:inherits="disabled,open"/>
michael@0 615 <children includes="menupopup"/>
michael@0 616 </content>
michael@0 617 </binding>
michael@0 618 </bindings>

mercurial