列表单元 XUL 中的按钮

发布于 2024-12-06 01:18:08 字数 583 浏览 3 评论 0原文

有没有办法让列表单元格中的按钮在 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>

该按钮在列表之外工作正常,但当它位于列表中时,我的鼠标指针甚至无法将其识别为按钮(通过更改为手形指针)。有什么想法吗?

Is there a way to get buttons in a listcell to work in XUL? I'm not sure what is stopping it from running. The XUL looks like :

<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>

The button works fine outside of the list but my mouse pointer doesn't even recognize it as a button (by changing to a hand pointer) when it's in the list. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流云如水 2024-12-13 01:18:08

按钮和其他控制元素可以在标准列表项中使用,不需要使用richlistbox或树。神奇的技巧是 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>

Buttons and other control elements can be used in a standard listitem, it is not required to use richlistbox or tree. The magic trick is the allowevents attribute. You might also want to wrap the buttons in a listcell itself so they get their own column.

<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>
羅雙樹 2024-12-13 01:18:08

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

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

列表单元格可以具有默认内容(如果您仅添加 label 属性并且没有内容,就会得到该内容)或您想要的任何内容 - 但是对于后者,您实际上必须显式地将内容放入 标记中。

编辑:实际上,更重要的问题是的内容相当有限,它大多局限于纯文本。这就是为什么更通用的 小部件具有已开发。但是它不支持表格内容。

You need to put the buttons inside the list cell:

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

A list cell can either have the default contents (which is what you get if you simply add a label attribute and no contents) or anything you want - but for the latter you actually have to put the contents into the <listcell> tag explicitly.

Edit: Actually, the more important problem is that <listbox> is rather restricted concerning its contents, it is mostly limited to plain text. Which is why the more generic <richlistbox> widget has been developed. It doesn't support tabular content however.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文