单击Firefox工具栏按钮中的坐标



我想从Firefox扩展中的工具栏图标中获取点击坐标。

我使用的代码如下://Toolbar code

<?xml version="1.0"?>                 
<overlay id="myext-toolbar-Overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<?xml-stylesheet href="chrome://myext/skin/myextToolbarButton.css" type="text/css"?>
<script src="chrome://myext/content/myextExtension.js" type="application/x-javascript" />
<toolbarpalette id="BrowserToolbarPalette">
    <toolbarbutton id="myext-button" class="toolbarbutton-1"
      label="Button"
      tooltiptext="Clip Web Page"
      oncommand="myextExtension.showPopup(event);" >
    </toolbarbutton>
</toolbarpalette>
</overlay>

单击工具栏图标时,将显示一个弹出窗口。我想在单击工具栏图标的位置显示弹出窗口。

command事件不是鼠标事件,它可以通过不同的方式触发(鼠标和键盘是最常见的),因此您无法在此处获得鼠标位置。您可以为click事件定义一个处理程序,记住那里的event.screenX/event.screenY,并在command事件处理程序中使用它们,如果它们可用的话。但最好是给按钮添加一个popup属性,让系统来处理它。或者只使用<toolbarbutton type="menu">

最新更新