Bug 890137 - [Australis] Menu should appear on mousedown, not mouseup. r=mconley

This commit is contained in:
Jared Wein 2013-09-25 09:35:15 -04:00
parent 90f1167a48
commit 6d72a21ef2
3 changed files with 33 additions and 24 deletions

View File

@ -870,8 +870,7 @@
<toolbarbutton id="PanelUI-menu-button"
class="toolbarbutton-1"
label="&brandShortName;"
tooltiptext="&appmenu.title;"
oncommand="PanelUI.toggle(event);"/>
tooltiptext="&appmenu.title;"/>
</toolbaritem>
<hbox id="window-controls" hidden="true" pack="end" skipintoolbarset="true"

View File

@ -39,6 +39,9 @@ const PanelUI = {
return this[getKey] = document.getElementById(id);
});
}
this.menuButton.addEventListener("mousedown", this);
this.menuButton.addEventListener("keypress", this);
},
_eventListenersAdded: false,
@ -68,6 +71,8 @@ const PanelUI = {
}
this.helpView.removeEventListener("ViewShowing", this._onHelpViewShow);
this.helpView.removeEventListener("ViewHiding", this._onHelpViewHide);
this.menuButton.removeEventListener("mousedown", this);
this.menuButton.removeEventListener("keypress", this);
},
/**
@ -92,6 +97,11 @@ const PanelUI = {
* @param aEvent the event that triggers the toggle.
*/
toggle: function(aEvent) {
// Don't show the panel if the window is in customization mode,
// since this button doubles as an exit path for the user in this case.
if (document.documentElement.hasAttribute("customizing")) {
return;
}
this._ensureEventListenersAdded();
if (this.panel.state == "open") {
this.hide();
@ -104,7 +114,8 @@ const PanelUI = {
}
let anchor;
if (aEvent.type == "command") {
if (aEvent.type == "mousedown" ||
aEvent.type == "command") {
anchor = this.menuButton;
} else {
anchor = aEvent.target;
@ -142,6 +153,11 @@ const PanelUI = {
this._updatePanelButton(aEvent.target);
break;
}
case "mousedown":
// Fall through
case "keypress":
this.toggle(aEvent);
break;
}
},

View File

@ -104,17 +104,17 @@ CustomizeMode.prototype = {
CustomizableUI.addListener(this);
// Add a keypress listener and click listener to the tab-view-deck so that
// Add a keypress listener and mousedown listener to the tab-view-deck so that
// we can quickly exit customization mode when pressing ESC or clicking on
// the blueprint outside the customization container.
let deck = document.getElementById("tab-view-deck");
deck.addEventListener("keypress", this, false);
deck.addEventListener("click", this, false);
deck.addEventListener("keypress", this);
deck.addEventListener("mousedown", this);
// Same goes for the menu button - if we're customizing, a click to the
// Same goes for the menu button - if we're customizing, a mousedown to the
// menu button means a quick exit from customization mode.
window.PanelUI.hide();
window.PanelUI.menuButton.addEventListener("click", this, false);
window.PanelUI.menuButton.addEventListener("mousedown", this);
window.PanelUI.menuButton.open = true;
window.PanelUI.beginBatchUpdate();
@ -156,11 +156,6 @@ CustomizeMode.prototype = {
window.gNavToolbox.addEventListener("toolbarvisibilitychange", this);
// Same goes for the menu button - if we're customizing, a click to the
// menu button means a quick exit from customization mode.
window.PanelUI.menuButton.addEventListener("click", this, false);
window.PanelUI.menuButton.disabled = true;
document.getElementById("PanelUI-help").setAttribute("disabled", true);
document.getElementById("PanelUI-quit").setAttribute("disabled", true);
@ -188,9 +183,9 @@ CustomizeMode.prototype = {
CustomizableUI.removeListener(this);
let deck = this.document.getElementById("tab-view-deck");
deck.removeEventListener("keypress", this, false);
deck.removeEventListener("click", this, false);
this.window.PanelUI.menuButton.removeEventListener("click", this, false);
deck.removeEventListener("keypress", this);
deck.removeEventListener("mousedown", this);
this.window.PanelUI.menuButton.removeEventListener("mousedown", this);
this.window.PanelUI.menuButton.open = false;
this.window.PanelUI.beginBatchUpdate();
@ -703,6 +698,13 @@ CustomizeMode.prototype = {
this._onDragEnd(aEvent);
break;
case "mousedown":
if (aEvent.button == 0 &&
(aEvent.originalTarget == this.window.PanelUI.menuButton) ||
(aEvent.originalTarget == this.document.getElementById("tab-view-deck"))) {
this.exit();
aEvent.preventDefault();
return;
}
this._onMouseDown(aEvent);
break;
case "mouseup":
@ -713,14 +715,6 @@ CustomizeMode.prototype = {
this.exit();
}
break;
case "click":
if (aEvent.button == 0 &&
(aEvent.originalTarget == this.window.PanelUI.menuButton) ||
(aEvent.originalTarget == this.document.getElementById("tab-view-deck"))) {
this.exit();
aEvent.preventDefault();
}
break;
}
},