diff --git a/chrome/content/zotero/elements/toolbarbuttonDropmarker.js b/chrome/content/zotero/elements/menuToolbarbutton.js similarity index 59% rename from chrome/content/zotero/elements/toolbarbuttonDropmarker.js rename to chrome/content/zotero/elements/menuToolbarbutton.js index 729ca7ce45..6ce3083d25 100644 --- a/chrome/content/zotero/elements/toolbarbuttonDropmarker.js +++ b/chrome/content/zotero/elements/menuToolbarbutton.js @@ -27,9 +27,33 @@ { /** - * Extends MozToolbarbutton to use our own dropmarker image. + * Extends MozToolbarbutton to use our own dropmarker image and native menus. */ - class ToolbarbuttonDropmarker extends customElements.get('toolbarbutton') { + class MenuToolbarbutton extends customElements.get('toolbarbutton') { + constructor() { + super(); + this.addEventListener('mousedown', (event) => { + let popup = this.querySelector(':scope > menupopup'); + if (popup && this.getAttribute('nonnativepopup') != 'true') { + event.preventDefault(); + + let rect = this.getBoundingClientRect(); + popup.openPopupAtScreen( + window.screenX + rect.left, + window.screenY + rect.bottom, + true + ); + this.setAttribute('open', true); + + popup.addEventListener('popuphiding', (event) => { + if (event.target == popup) { + this.setAttribute('open', false); + } + }, { once: true }); + } + }); + } + static get dropmarkerFragment() { let frag = document.importNode( MozXULElement.parseXULToFragment(` @@ -42,7 +66,7 @@ } } - customElements.define("toolbarbutton-dropmarker", ToolbarbuttonDropmarker, { + customElements.define("menu-toolbarbutton", MenuToolbarbutton, { extends: "toolbarbutton", }); } diff --git a/chrome/content/zotero/zoteroPane.xhtml b/chrome/content/zotero/zoteroPane.xhtml index bd24280b14..e898bf38ed 100644 --- a/chrome/content/zotero/zoteroPane.xhtml +++ b/chrome/content/zotero/zoteroPane.xhtml @@ -83,7 +83,7 @@ Services.scriptloader.loadSubScript("chrome://zotero/content/elements/tagsBox.js", this); Services.scriptloader.loadSubScript("chrome://zotero/content/elements/relatedBox.js", this); Services.scriptloader.loadSubScript("chrome://zotero/content/elements/attachmentBox.js", this); - Services.scriptloader.loadSubScript("chrome://zotero/content/elements/toolbarbuttonDropmarker.js", this); + Services.scriptloader.loadSubScript("chrome://zotero/content/elements/menuToolbarbutton.js", this); Services.scriptloader.loadSubScript("chrome://zotero/content/tabs.js", this); Services.scriptloader.loadSubScript("chrome://zotero/content/zoteroPane.js", this); @@ -759,7 +759,7 @@ -->