XUL 按钮看起来像是禁用的并且不可“按下”。 (但是onclick函数被调用)
我正在开发一个 Firefox 扩展。我熟悉 JS、CSS、XML,但对 XUL 很陌生。
我想以在每个下载文件旁边添加一个按钮来重命名它的方式覆盖下载。我已经完成了(放置按钮并处理重命名逻辑)。
剩下的就是 UI。该按钮看起来像是禁用的,但显然不是,因为我可以单击它并出现弹出窗口。
这是现在的样子:
和相应的代码:
<xul:button label="Rename" tabindex="1" onclick="foo()"/>
添加 disabled="false “
没有帮助。我可以添加 style="color:black; text-shadow:0 0;"
和 这使它看起来像预期,但有几个问题(我猜禁用-类似的外观可能是原因):
- 我添加的按钮不像本机“清除列表”按钮那样“可按下”(按下它不会改变其外观,即它不会“下降”)。但是,
foo()
被调用。 - 我无法从键盘上使用 Tab 导航到按钮。
- 我读过应该更喜欢
command
/oncommand
而不是onclick
(例如因为 Tab 导航),但在我的示例中,只有onclick
调用foo()
。另外两个不起作用。
如果需要更详细的代码(我完全从其他扩展借用了它):
<binding id="download-done" extends="chrome://mozapps/content/downloads/download.xml#download-base">
<content>
<xul:hbox flex="1">
...
<xul:vbox pack="start" flex="1">
...
<xul:hbox align="center" flex="1">
<xul:label xbl:inherits="value=status,tooltiptext=statusTip" crop="end" flex="1" class="status"/>
<xul:button label="Rename" tabindex="1" onclick="foo()"/>
</xul:hbox>
</xul:vbox>
</xul:hbox>
</content>
</binding>
非常感谢帮助。
编辑 1
我上面提供的代码取自原始 Firefox download.xml (
) 并仅通过添加我的
。
为了让事情变得更奇怪,我从同一个文件中获取了另外两个绑定(
和
) 并向它们添加了完全相同的
,并且在这两种情况下,按钮都是“可推动的”并且是黑色的(在简短、正常、理应如此 是)。即使没有显式设置 tabindex
,也可以使用 Tab 从键盘进行导航。
I'm developing a Firefox extension. I'm familiar with JS, CSS, XML but new to XUL.
I want to override Downloads in the way that adds a button next to each downloaded file to rename it. I've already done it (placing a button and handling rename logic).
The thing that left is UI. The button looks like disabled, but apparently is not, because I can click it and the popup appears.
Here it is how it looks now:
and the corresponding code:
<xul:button label="Rename" tabindex="1" onclick="foo()"/>
Adding disabled="false"
doesn't help. I can add style="color:black; text-shadow:0 0;"
and this makes it look like intended, but there are several problems (and I guess disabled-like look might be the cause):
- The button I added is not "pushable" in the manner like the native "Clear list" button (pushing it doesn't change its look, i.e. it doesn't "go down"). However,
foo()
is invoked. - I can't navigate to the button with Tab from keyboard.
- I've read one should prefer
command
/oncommand
instead ofonclick
(because of Tab navigation for instance), but in my example, onlyonclick
invokesfoo()
. The two other don't work.
In case more detailed code is needed (I borrowed it entirely from some other extension):
<binding id="download-done" extends="chrome://mozapps/content/downloads/download.xml#download-base">
<content>
<xul:hbox flex="1">
...
<xul:vbox pack="start" flex="1">
...
<xul:hbox align="center" flex="1">
<xul:label xbl:inherits="value=status,tooltiptext=statusTip" crop="end" flex="1" class="status"/>
<xul:button label="Rename" tabindex="1" onclick="foo()"/>
</xul:hbox>
</xul:vbox>
</xul:hbox>
</content>
</binding>
Help greatly appreciated.
Edit 1
The code I presented above was taken from original Firefox download.xml (<binding id="download-done">
) and changed only by adding my <xul:button>
.
For the things to be even more weird, I've taken, from the same file, two another bindings ( <binding id="download-paused">
and <binding id="download-downloading">
) and added exactly the same <xul:button>
to them, and in both cases, the button is both "pushable" and black (in short, normal, as it should be). It is also navigable from keyboard with Tab, even without setting tabindex
explicitly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论