Xul's listitem command attribute does not work?
I've made this sample, and it's just not working:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<commandset>
<command id="cmd_dump" oncommand="dump('ok');" />
</commandset>
<vbox style="background:#FFFFFF;" flex="1">
<spacer flex="1" />
<hbox pack="center">
<listbox flex="1">
<listitem label="Test1" command="cmd_dump" />
<listitem label="Test2" command="cmd_dump" />
</listbox>
</hbox>
<spacer flex="1" />
</vbox>
</window>
How to make it work?
I didn't work for me either. But making type = checkbox does fire the command. You can get rid of the checkbox using absolute positioning and negative margins but thats an ugly hack.
A better way would be to listen for the click event of the <listitem> in Javascript.
As Cedric said, it might be a bug although the example at controllers - MDC works.
Tom - I come to the same conclusion as yours, having tried in a different way to make a command work, and quickly checked on the Internet (I even found one of your posts on a forum from the beginning of the month).
However, have you tried it with an old version of Firefox (or an old version of the XULRunner engine)? Maybe you can change slightly want you want your screen to be, like using a command when going out of it, so that you can avoid this problem?
It may be worth asking your question on this channel : #xul on irc.mozilla.org. They may end up telling you it's a bug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With