Mozilla “Jetpack” Add-On: Anchor Panel to Widget

一世执手 提交于 2020-02-20 06:15:28

问题


I'm making a Jetpack extension in which a widget opens a panel. Clicking the widget opens the panel as expected (anchored in the lower-right corner to the widget). But if I call widget.panel.show() from my code, the panel opens detached from the widget, centered in the screen, floating in space.

In short, how can I fix this?

  1. Can I simulate a click event on the widget (somehow) instead of calling widget.panel.show()?

  2. Can I force the panel to anchor to the widget?

This question has a solution that worked in the previous Jetpack API, but I can't translate to the new interface: Using positioning 'Panel' in new Jetpack API


回答1:


panel.show(require("tab-browser").activeTab.ownerDocument.getElementById('widget:yourAddonId@package.json-yourWidgetId'));

Works for me with Addon SDK 1.8.1
Where:
yourAddonId@package.json - your addon id from package.json
yourWidgetId - your widget id




回答2:


panel.show(widget)

isn't working?



来源:https://stackoverflow.com/questions/5478434/mozilla-jetpack-add-on-anchor-panel-to-widget

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!