Mozilla“喷气背包"附加组件:将面板锚定到小部件 [英] Mozilla "Jetpack" Add-On: Anchor Panel to Widget

查看:21
本文介绍了Mozilla“喷气背包"附加组件:将面板锚定到小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个 Jetpack 扩展,其中一个小部件会打开一个面板.单击小部件会按预期打开面板(锚定在小部件的右下角).但是,如果我从我的代码中调用 widget.panel.show(),面板会打开,与小部件分离,位于屏幕中央,漂浮在空间中.

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. 我可以模拟小部件上的点击事件(以某种方式)而不是调用 widget.panel.show()?

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

我可以强制面板锚定到小部件吗?

Can I force the panel to anchor to the widget?

这个问题有一个在以前的 Jetpack API 中有效的解决方案,但我无法转换为新界面:在新的 Jetpack API 中使用定位面板"

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

推荐答案

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

适用于我的插件 SDK 1.8.1
地点:
yourAddonId@package.json - 来自 package.json
的插件 IDyourWidgetId - 你的小部件 ID

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

这篇关于Mozilla“喷气背包"附加组件:将面板锚定到小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆