Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Current »

Introduction

Menulists are the root elements of drop-downs (combo boxes). While you can declare the contents of a menulist in the XUL document, most often you'll want to bind a collection to the "elements" property to generate the menuitems.

Property

Fires Events

Possible Values

Notes

binding (String)

No

 

The property to extract a label value from each item bound to this control (i.e. a value of "name" would translate to a "getName()" call on each item in the bound collection

editable (bool)

No

 

Allows the editing of the property for the object bound to the menuitem

elements (Collection)

No

 

Setting a collection on the property will populate the menulist based on the collection. The label displayed will be extracted from the Objects based on the value set in the "binding" property

selectedIndex (int)

Yes

 

Sets the current value on the menulist. This property is also fired on user change.

selectedItem (Object)

Yes

 

Similar to selectedIndex only based on the objects bound to the menulist.

value (String)

No

 

Calling this will set the value for the currently selected item. Only meaningful when the menulist is editable

oncommand (String)

No

 

"controller.method()" format. Fired when the currently selected item is changed.

None.

<menulist id="list" pen:binding="name">
    <menupopup>
        <menuitem label="Value 1" />
        <menuitem label="Value 2" />
    </menupopup>
</menulist>

Example binding, usually defined in a controller's init. This populates the menulist with the contents of the method getListItems() in the controller:

XulMenuList<String> list = (XulMenuList<String>) document.getElementById("list");
Binding b = bf.createBinding(this, "listItems", list, "elements");
b.fireSourceChanged();
  • No labels