【问题标题】:XBL Use Binding as Child in Other Within Same XMLXBL 在同一 XML 中的其他中使用绑定作为子项
【发布时间】:2014-08-09 06:58:06
【问题描述】:

我有这个 xml 绑定:

<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:xbl="http://www.mozilla.org/xbl">
    <binding id="tbb" role="xul:toolbarbutton" extends="chrome://global/content/bindings/button.xml#button-base">
        <resources>
<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:xbl="http://www.mozilla.org/xbl">
    <binding id="tbb" role="xul:toolbarbutton" extends="chrome://global/content/bindings/button.xml#button-base">
        <resources>
            <stylesheet src="chrome://global/skin/toolbarbutton.css" />
        </resources>
        <content>
            <children includes="observes|template|menupopup|panel|tooltip" />
            <xul:image class="toolbarbutton-icon" xbl:inherits="validate,src=image,label" flex="0" />
            <xul:image class="profilist-badge" xbl:inherits="validate,src=badge,label" width="1" flex="0" />
            <xul:label class="toolbarbutton-text" crop="right" flex="1" xbl:inherits="value=label,accesskey,crop,wrap" />
            <xul:label class="toolbarbutton-multiline-text" flex="1" xbl:inherits="xbl:text=label,accesskey,wrap" />
        </content>
    </binding>
    <binding id="tbb-box">
        <content>
            <children/>
            <xul:box class="profilist-submenu">
                <xul:image class="profilist-closed" />
                <xul:image class="profilist-build" />
                <xul:image class="profilist-safe" />
                <xul:image class="profilist-default" />
                <xul:image class="profilist-rename" />
                <xul:image class="profilist-del" />
            </xul:box>
        </content>
    </binding>
</bindings>

我想做的是放置一个toolbarbutton,它使用我在上面定义的绑定profilist-tbb。我想在 XBL 文件中执行此操作。而不是让 css 告诉应用您知道的绑定?

我试过了,但工具栏按钮甚至没有被创建:(

<binding id="tbb-box">
    <resources>
        <stylesheet src="chrome://global/skin/toolbarbutton.css" />
    </resources>
    <content>
        <toolbarbutton class="rawr"></toolbarbutton>
        <xul:box class="profilist-submenu">
            <xul:image class="profilist-closed" />
            <xul:image class="profilist-build" />
            <xul:image class="profilist-safe" />
            <xul:image class="profilist-default" />
            <xul:image class="profilist-rename" />
            <xul:image class="profilist-del" />
        </xul:box>
    </content>
</binding>

谢谢

【问题讨论】:

  • Err.. 你在尝试什么?我无法理解你的问题?另外,绑定中的重复行是复制/粘贴错误,还是真的像 XBL 文件中的那样?
  • 真的是这样 :( 感谢您的回复,我非常需要帮助。我的问题是,当我禁用 box 时,我希望工具栏按钮与其他一些东西一起继承它。所以我试图制作一个新的 xbl 元素,它是一个工具栏按钮。我希望使用我的 xml #profilist-tbb 中的第一个绑定来扩展该工具栏按钮,然后我想将该扩展的工具栏按钮放在我的框中 #profilist-tbb-box

标签: binding firefox-addon xbl


【解决方案1】:

我认为这不是最好的解决方案,但这就是我让它发挥作用的方式。我在 id profilist-tbb-box 的 xbl 中给了工具栏按钮一个类,然后我从 css 将绑定应用到了我在其中创建的 toolbarbutton

xbl.xml:

<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:xbl="http://www.mozilla.org/xbl">
    <binding id="tbb" role="xul:toolbarbutton" extends="chrome://global/content/bindings/button.xml#button-base">
        <resources>
            <stylesheet src="chrome://global/skin/toolbarbutton.css" />
        </resources>
        <content>
            <children includes="observes|template|menupopup|panel|tooltip" />
            <xul:image class="toolbarbutton-icon" xbl:inherits="validate,src=image,label" flex="0" />
            <xul:image class="profilist-badge" xbl:inherits="validate,src=badge,label" width="1" flex="0" />
            <xul:label class="toolbarbutton-text" crop="right" flex="1" xbl:inherits="value=label,accesskey,crop,wrap" />
            <xul:label class="toolbarbutton-multiline-text" flex="1" xbl:inherits="xbl:text=label,accesskey,wrap" />
        </content>
    </binding>
    <binding id="tbb-box">
        <content>
            <toolbarbutton class="profilist-tbb" xbl:inherits="label,disabled"/>
            <xul:box class="profilist-submenu" xbl:inherits="disabled">
                <xul:image class="profilist-closed" xbl:inherits="disabled"/>
                <xul:image class="profilist-build"  xbl:inherits="disabled"/>
                <xul:image class="profilist-safe"  xbl:inherits="disabled"/>
                <xul:image class="profilist-default"  xbl:inherits="disabled"/>
                <xul:image class="profilist-rename"  xbl:inherits="disabled"/>
                <xul:image class="profilist-del"  xbl:inherits="disabled"/>
            </xul:box>
        </content>
    </binding>
</bindings>

来自css:

.profilist-tbb-box {
  -moz-binding: url('chrome://profilist/content/xbl.xml#tbb-box');
}
.profilist-tbb {
  -moz-binding: url('chrome://profilist/content/xbl.xml#tbb');
}

【讨论】:

    猜你喜欢
    • 2012-11-28
    • 2021-12-22
    • 1970-01-01
    • 1970-01-01
    • 2011-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多