本文介绍了工具栏上下文菜单显示在toolbarbutton的xul面板里面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个 toolbarbutton ,单击时显示一个面板。当我右键单击面板我收到以下内容: 这是相同的上下文菜单,显示当我点击主工具栏或甚至是toolbarbuttons时。 xul是: < toolbarpalette id =BrowserToolbarPalette> < toolbarbutton id =testToolbarIcon image =chrome://myext/content/images/aicon.png type =panel class =toolbarbutton -1 chromeclass-toolbar-additional> < panel id =testPanel type =arrow level =parent> < vbox id =testboxalign =topwidth =200height =200> < label value =Test Label/> < textbox>< / textbox> < / vbox> < / panel> < / toolbarbutton> < / toolbarpalette> 有关如何阻止这种行为传递给面板的想法吗?$ b $添加一个点击事件监听器到面板和 .preventDefault() 和/或 .stopPropagation() 应该做的伎俩,如果内存服务的权利。另一种方法是根本不使用 type =面板 / code>按钮,把面板放在别的地方(一个弹出菜单),使用 .openPopup()从js打开面板。为了让按钮状态正确,当显示弹出窗口时,你需要做一个 button.open = true ,并且一旦它被隐藏了,就恢复它(至少这就是下载指示器按钮)。 I have a toolbarbutton that when clicked, shows a panel. When i right click the panel i'm getting the following:This is the same context menu that shows when i click on the main toolbar or even the toolbarbuttons.The xul is:<toolbarpalette id="BrowserToolbarPalette"> <toolbarbutton id="testToolbarIcon" image="chrome://myext/content/images/aicon.png" type="panel" class="toolbarbutton-1 chromeclass-toolbar-additional"> <panel id="testPanel" type="arrow" level="parent"> <vbox id="testbox" align="top" width="200" height="200"> <label value="Test Label" /> <textbox></textbox> </vbox> </panel> </toolbarbutton></toolbarpalette>Any idea on how to stop this behavior from passing to the panel? 解决方案 Adding an click event listener to the panel and .preventDefault() and/or .stopPropagation() should do the trick, if memory served right.Another way is simply not to use a type="panel" button, put the panel somewhere else (a popupset) and open the panel from js using .openPopup(). To get the button state right, you need to do a button.open = true when the popup is shown, and revert that once it is hidden again (at least that is what the download-indicator button does). 这篇关于工具栏上下文菜单显示在toolbarbutton的xul面板里面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-23 18:48