Fixing osx menus. Also refresh context and file menus when a custom container is created. Fixes #127
This commit is contained in:
parent
fe1decef4c
commit
885b90709b
1 changed files with 38 additions and 37 deletions
27
index.js
27
index.js
|
@ -1027,26 +1027,27 @@ ContainerWindow.prototype = {
|
|||
// Generic menu configuration.
|
||||
_configureMenu(menuId, excludedContainerCb, clickCb, arrayName) {
|
||||
const menu = this._window.document.getElementById(menuId);
|
||||
this._disableElement(menu, arrayName);
|
||||
if (!this._disableElement(menu, arrayName)) {
|
||||
return Promise.resolve(null);
|
||||
// Delete stale menu that isn't native elements
|
||||
while (menu.firstChild) {
|
||||
menu.removeChild(menu.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
const menupopup = this._window.document.createElementNS(XUL_NS, "menupopup");
|
||||
menu.appendChild(menupopup);
|
||||
|
||||
menupopup.addEventListener("command", clickCb);
|
||||
menupopup.addEventListener("popupshowing", e => {
|
||||
return this._createMenu(e, excludedContainerCb);
|
||||
});
|
||||
|
||||
return Promise.resolve(null);
|
||||
return this._createMenu(menupopup, excludedContainerCb);
|
||||
},
|
||||
|
||||
_createMenu(event, excludedContainerCb) {
|
||||
while (event.target.hasChildNodes()) {
|
||||
event.target.removeChild(event.target.firstChild);
|
||||
_createMenu(target, excludedContainerCb) {
|
||||
while (target.hasChildNodes()) {
|
||||
target.removeChild(target.firstChild);
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
ContainerService.queryIdentities().then(identities => {
|
||||
const fragment = this._window.document.createDocumentFragment();
|
||||
|
||||
|
@ -1079,10 +1080,10 @@ ContainerWindow.prototype = {
|
|||
fragment.appendChild(menuitem);
|
||||
});
|
||||
|
||||
event.target.appendChild(fragment);
|
||||
}).catch(() => {});
|
||||
|
||||
return true;
|
||||
target.appendChild(fragment);
|
||||
resolve();
|
||||
}).catch(() => {reject();});
|
||||
});
|
||||
},
|
||||
|
||||
// This timer is used to hide the panel auto-magically if it's not used in
|
||||
|
|
Loading…
Add table
Reference in a new issue