<combobox>

combobox displays a dropdown list of selectable items.

JavaScript: combobox

Extends Basecombobox

A combobox is a common UI element for displaying a pop-up list associated with a text field. The selected text of the combobox is displayed within the text field. This field is an LzInputText field if the editable of the combobox is true (the default), or a static LzText field if it is false.

The number of items shown in the combobox can be set using the shownitems attribute. If there are more items available than are shown, a scrollbar will be created automatically.

The list of items in a combobox can be created explicity using the <textlistitem> tag with assigned text and value attributes.

<canvas width="200" height="100">
 <combobox id="cbox" x="5" y="5" width="130" editable="false">
    <textlistitem text="Dark Blue"  value="0x000055"/>
    <textlistitem text="Turquoise"  value="0x66dddd"/>
    <textlistitem text="Light Blue" value="0xaaddff"/>
  </combobox>
  <view x="150" y="5" width="20" height="20"
        bgcolor="${cbox.value}"/>
</canvas>


A combobox can also be populated by assigning a datapath to a <textlistitem>'. Also the number of items shown can be set with the shownitems attribute.

<canvas width="200" height="130">
  <dataset name="items">
    <item value="item1">item one</item>
    <item value="item2">item two</item>
    <item value="item3">item three</item>
    <item value="item4">item four</item>
  </dataset>

  <combobox x="5" y="5"
            width="130"  
            shownitems="3"
            defaulttext="choose one..."  >
    <textlistitem datapath="items:/item" text="$path{'text()'}"
                  value="$path{'@value'}"/>
  </combobox>
</canvas>

Finally, a combox can also have custom items in its list by tending the listitem class. An example of this is shown below:

<canvas width="200" height="130">
  <class name="mylistitem" extends="listitem" width="100%" height="20" >
   <attribute name="text" value="" type="string"/>
   <!-- place a red square in the left hand side of mylistitem -->
   <view bgcolor="red" width="10" height="10" x="5" y="5"/>
   <!-- constrain the text to the text attribute of listitem -->
   <text x="20" text="${classroot.text}" fgcolor="0x4B4B4B">
   </text>
  </class>

  <dataset name="items">
    <item value="item1">item one</item>
    <item value="item2">item two</item>
    <item value="item3">item three</item>
    <item value="item4">item four</item>
  </dataset>

  <combobox x="5" y="5"
            width="130" editable="false">
    <mylistitem datapath="items:/item" text="$path{'text()'}"
                value="$path{'@value'}"/>
  </combobox>
</canvas>

For details on how this component is constructed see the Using the Laszlo Components chapter of the Guide.

Attributes

Attributes inherited from Basecombobox

attachoffset, autoscrollbar, bordersize, dataoption, defaultselection, defaulttext, editable, isopen, itemclassname, min_width, ondefaultselection, selected, shownitems, spacing, text_width, text_x, text_y

Attributes inherited from Basecomponent

doesenter, enabled, hasdefault, isdefault, style, styleable, text

Attributes inherited from Baseformitem

changed, ignoreform, onchanged, onvalue, rollbackvalue, submit, submitname

Attributes inherited from Basevaluecomponent

value

Attributes inherited from Node

class, classroot, cloneManager, datapath, id, ignoreAttribute, ignoreplacement, immediateparent, initstage, name, nodeLevel, onconstruct, oninit, parent, placement, subnodes

Attributes inherited from View

aaactive, aadescription, aaname, aasilent, aatabindex, align, bgcolor, clickable, clickregion, clip, cursor, defaultplacement, fgcolor, focusable, focustrap, font, fontsize, fontstyle, frame, framesloadratio, hassetheight, hassetwidth, height, layout, loadratio, mask, onblur, onclick, ondata, ondblclick, onfocus, onkeydown, onkeyup, onmousedown, onmouseout, onmouseover, onmouseup, onselect, opacity, options, pixellock, play, resource, resourceheight, resourcewidth, rotation, selectiontype, showhandcursor, source, stretches, subviews, totalframes, unstretchedheight, unstretchedwidth, valign, visible, width, x, xoffset, y, yoffset


Methods

Methods inherited from basecombobox

addItem, clearSelection, getItem, getItemAt, getSelection, getText, getValue, removeItem, removeItemAt, select, selectItem, selectItemAt, setDefaultSelection, setItemclassname, setOpen, setText, setWidth, toggle

Methods inherited from basecomponent

doEnterDown, doEnterUp, doSpaceDown, doSpaceUp, setStyle, setTint, updateDefault

Methods inherited from baseformitem

applyData, commit, findForm, init, rollback, setChanged, setValue, toXML, updateData

Methods inherited from LzNode

animate, applyConstraint, childOf, completeInstantiation, createChildren, dataBindAttribute, destroy, determinePlacement, getAttribute, getOption, getUID, lookupSourceLocator, searchImmediateSubnodes, searchSubnodes, setAttribute, setDatapath, setID, setName, setOption

Methods inherited from LzView

addProxyPolicy, addSubview, bringToFront, construct, containsPt, getAttributeRelative, getBounds, getColor, getColorTransform, getContextMenu, getCurrentTime, getDepthList, getHeight, getID3, getMouse, getPan, getTotalTime, getVolume, getWidth, measureHeight, measureWidth, play, releaseLayouts, removeProxyPolicy, searchParents, searchSubviews, seek, sendBehind, sendInFrontOf, sendToBack, setAAActive, setAADescription, setAAName, setAASilent, setAATabIndex, setAlign, setAttributeRelative, setBGColor, setClickable, setColor, setColorTransform, setContextMenu, setCursor, setHeight, setLayout, setOpacity, setPan, setPlay, setResource, setResourceNumber, setRotation, setShowHandCursor, setSource, setValign, setVisible, setVolume, setX, setY, shouldYieldFocus, stop, stretchResource, unload, updateResourceSize


Events

Events inherited from LzNode

onconstruct, ondata, oninit

Events inherited from LzView

onaddsubresource, onaddsubview, onblur, onclick, ondblclick, onerror, onfocus, onframe, onheight, onlastframe, onload, onmousedown, onmousedragin, onmousedragout, onmouseout, onmouseover, onmouseup, onmouseupoutside, onopacity, onplay, onremovesubview, onstop, ontimeout, onwidth, onx, ony