mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 23:32:26 +01:00
More reliable Menu mode handling. Closes issue #335.
This commit is contained in:
@@ -493,6 +493,29 @@ var Events = Module("events", {
|
|||||||
|
|
||||||
this._activeMenubar = false;
|
this._activeMenubar = false;
|
||||||
this.listen(window, this, "events", true);
|
this.listen(window, this, "events", true);
|
||||||
|
|
||||||
|
this.popups = {
|
||||||
|
active: [],
|
||||||
|
|
||||||
|
update: function update(elem) {
|
||||||
|
if (elem) {
|
||||||
|
if (elem instanceof Ci.nsIAutoCompletePopup
|
||||||
|
|| elem.localName == "tooltip"
|
||||||
|
|| !elem.popupBoxObject)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!~this.active.indexOf(elem))
|
||||||
|
this.active.push(elem);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.active = this.active.filter(function (e) e.popupBoxObject.popupState != "closed");
|
||||||
|
|
||||||
|
if (!this.active.length && !events._activeMenubar)
|
||||||
|
modes.remove(modes.MENU, true);
|
||||||
|
else if (modes.main != modes.MENU)
|
||||||
|
modes.push(modes.MENU);
|
||||||
|
}
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
signals: {
|
signals: {
|
||||||
@@ -1118,13 +1141,13 @@ var Events = Module("events", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
DOMMenuBarActive: function () {
|
DOMMenuBarActive: function onDOMMenuBarActive() {
|
||||||
this._activeMenubar = true;
|
this._activeMenubar = true;
|
||||||
if (modes.main != modes.MENU)
|
if (modes.main != modes.MENU)
|
||||||
modes.push(modes.MENU);
|
modes.push(modes.MENU);
|
||||||
},
|
},
|
||||||
|
|
||||||
DOMMenuBarInactive: function () {
|
DOMMenuBarInactive: function onDOMMenuBarInactive() {
|
||||||
this._activeMenubar = false;
|
this._activeMenubar = false;
|
||||||
modes.remove(modes.MENU, true);
|
modes.remove(modes.MENU, true);
|
||||||
},
|
},
|
||||||
@@ -1376,24 +1399,27 @@ var Events = Module("events", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
popupshowing: function onPopupShowing(event) {
|
||||||
|
this.popups.update(event.originalTarget);
|
||||||
|
},
|
||||||
|
|
||||||
popupshown: function onPopupShown(event) {
|
popupshown: function onPopupShown(event) {
|
||||||
let elem = event.originalTarget;
|
let elem = event.originalTarget;
|
||||||
|
this.popups.update(elem);
|
||||||
|
|
||||||
if (elem instanceof Ci.nsIAutoCompletePopup) {
|
if (elem instanceof Ci.nsIAutoCompletePopup) {
|
||||||
if (modes.main != modes.AUTOCOMPLETE)
|
if (modes.main != modes.AUTOCOMPLETE)
|
||||||
modes.push(modes.AUTOCOMPLETE);
|
modes.push(modes.AUTOCOMPLETE);
|
||||||
}
|
}
|
||||||
else if (elem.localName !== "tooltip")
|
else if (elem.localName !== "tooltip") {
|
||||||
if (Events.isHidden(elem)) {
|
if (Events.isHidden(elem))
|
||||||
if (elem.hidePopup && Events.isHidden(elem.parentNode))
|
if (elem.hidePopup && Events.isHidden(elem.parentNode))
|
||||||
elem.hidePopup();
|
elem.hidePopup();
|
||||||
}
|
}
|
||||||
else if (modes.main != modes.MENU)
|
|
||||||
modes.push(modes.MENU);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
popuphidden: function onPopupHidden(event) {
|
popuphidden: function onPopupHidden(event) {
|
||||||
if (window.gContextMenu == null && !this._activeMenubar)
|
this.popups.update();
|
||||||
modes.remove(modes.MENU, true);
|
|
||||||
modes.remove(modes.AUTOCOMPLETE);
|
modes.remove(modes.AUTOCOMPLETE);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -608,7 +608,11 @@ var Modes = Module("modes", {
|
|||||||
|
|
||||||
mappings.add([modes.MENU], ["<Esc>"],
|
mappings.add([modes.MENU], ["<Esc>"],
|
||||||
"Close the current popup",
|
"Close the current popup",
|
||||||
function () { return Events.PASS_THROUGH; });
|
function () {
|
||||||
|
if (modes.popup.active.length)
|
||||||
|
return Events.PASS_THROUGH;
|
||||||
|
modes.pop();
|
||||||
|
});
|
||||||
|
|
||||||
mappings.add([modes.MENU], ["<C-[>"],
|
mappings.add([modes.MENU], ["<C-[>"],
|
||||||
"Close the current popup",
|
"Close the current popup",
|
||||||
|
|||||||
@@ -821,8 +821,8 @@ var DOM = Class("DOM", {
|
|||||||
};
|
};
|
||||||
|
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
var t = this.constructor.types[type];
|
var t = this.constructor.types[type] || "";
|
||||||
var evt = doc.createEvent((t || "HTML") + "Events");
|
var evt = doc.createEvent(t + "Events");
|
||||||
|
|
||||||
let defaults = DEFAULTS[t || "HTML"];
|
let defaults = DEFAULTS[t || "HTML"];
|
||||||
update(defaults, this.constructor.defaults[type]);
|
update(defaults, this.constructor.defaults[type]);
|
||||||
|
|||||||
Reference in New Issue
Block a user