Menulists may look like HTML
option
elements, but they
are quite diferent. They can be located in menubars and buttons, and
they can contain checkboxes, radiobuttons en submenu's. Nevertheless,
I use the HTML approach below to distinguish three types of lists:
single select flat list
The plain
<menulist class="formwidget"
behaves like
a HTML single select
option
element. It should only contain plain menuitems.
The menulist holds the name and label
of the widget, the selectedItem holds the value. If the selectedItem has no value, it's label
is used as value.
When seeded, the menulist matches any seed with the same
name
.
It searches for a menuitem with the same
value
as the
matching seed and selects that. If none is found,
it sets the menulists value and label to the seeds values.
multiple select flat list
The
<menulist class="formwidget" select="checkbox"
and
<menulist class="formwidget" select="radio"
behave like
the HTML multiple select
option
element. They should only
contain menuitems with
type="checkbox"
or
type="radio"
,
respectively. The menulist holds the name
of the widget, the checked items hold the values and labels.
If a checked item has no value, it's label is used as value.
The label of the menulist reflects the label of all checked menuitems,
separated by the value of the
labelseparator
attribute.
When seeded, the menulist matches any seed with the same
name
.
It searches for menuitems with the same
value
as the
matching seed and checks those. If none is found, a menuitem
with that label and value is appended and checked.
other menulists
If you mix different types of menuitems
or have nested menus in your menu, you dont want this kind of formwidget.
Use
menuitem formwidgets.
Note: in XUL, menulists have label and value properties.
Once you select an item, the menulist's properties are set; with
an editable menulist, this turns the menuitem's label into the
menulist's value. reversely, with non-editable menulists the menulist's
label can be changed by javascript without changing the selected item's label.
Setting the menulist's value property tries to select a menuitem.
Confusing as it is, formwidgets try to follow that behaviour.
Note2: in XUL, a menuitem is checked if it has an attribute checked,
regardless of the value. To uncheck an item, remove the attribute.
Note3: in XUL, menuitems with type=radio have a name attribute. the idea is
that menuitems with the same name belong to the same group and you can only
select one item from such a group. this name has nothing to do with formwidgets.
The menubar is not implemented.
Example: