繁体   English   中英

XUL列表单元中的按钮

[英]Buttons in a listcell XUL

有没有办法让列表单元中的按钮在XUL中工作? 我不确定是什么阻止了它的运行。 XUL看起来像:

<listitem id = "1">
    <listcell label = "OK Computer"/>
    <listcell label = "Radiohead"/>
    <listcell label = "1997"/>
    <listcell label = "Platinum"/>
    <listcell label = "5/5"/>
    <listcell label = "Alternative Rock"/>  
    <button label = "Edit" oncommand= "alert('Hello World');"/>
    <button label = "Delete" oncommand = "deleteItem();"/>  
</listitem>

该按钮在列表外部工作正常,但当鼠标在列表中时,我的鼠标指针甚至无法识别为按钮(通过更改为手形指针)。 有任何想法吗?

按钮和其他控件元素可以在标准listitem中使用,不需要使用richlistbox或tree。 魔术是allowevents属性。 您可能还希望将按钮包装在列表单元格中,以便它们获得自己的列。

<listitem id="1" allowevents="true">
    <listcell label="OK Computer"/>
    <listcell label="Radiohead"/>
    <listcell label="1997"/>
    <listcell label="Platinum"/>
    <listcell label="5/5"/>
    <listcell label="Alternative Rock"/>  
    <listcell>
        <button label="Edit" oncommand="alert('Hello World');"/>
        <button label="Delete" oncommand="deleteItem();"/>  
    </listcell>
</listitem>

您需要将按钮放在列表单元格内:

<listcell>
  <button label="Edit" oncommand="alert('Hello World');"/>
</listcell>

列表单元可以具有默认内容(如果您只是添加label属性而没有任何内容,则将获得默认内容)或任何您想要的内容-但是对于后者,您实际上必须将内容明确地放入<listcell>标记中。

编辑 :实际上,更重要的问题是<listbox>在其内容方面受到限制,它主要限于纯文本。 这就是为什么开发了更通用的<richlistbox>小部件的原因。 但是,它不支持表格内容。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM