<basecombobox>

baseclass for a combobox

JavaScript: basecombobox

Extends Baseformitem

Extend this base class to create a combobox with a custom popup control, and to change the size of the font.

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> tags with assigned text and value attributes.

Example 1. custom appearance and font for a combobox
<canvas width="200" height="100">
  <font name="smallfont" src="verity/verity9.ttf"/>

  <class name="minicombo" extends="basecombobox" font="smallfont"
         bgcolor="0xeaeaea" editable="false" height="14">
    <attribute name="text_y" value="-2"/>
    <view bgcolor="green" x="${parent.width-10}"
          y="3" height="8" width="8"
          placement="bkgnd" onclick="parent.toggle()" />
  </class>

  <class name="minilistitem" extends="textlistitem"
         font="smallfont" text_y="-2" height="12"/>

  <minicombo x="20" y="20"  >
    <minilistitem value="1">one</minilistitem>
    <minilistitem value="2">two</minilistitem>
    <minilistitem value="3">three</minilistitem>
  </minicombo>
</canvas>

For more use cases of <basecombobox>, see examples in <combobox>.

Attributes
Name Usage Type (Tag) Type (JS) Default Category
attachoffset Tag & JS number Number -1 setter
 

The vertical offset of the floatinglist attached to this combobox.


autoscrollbar Tag & JS expression any true setter
 

Whether a scrollbar should automatically show up when there are more items than shownitems.


bordersize Tag & JS expression any 1 setter
 

The border size ( in pixels ) of the popup list.


dataoption Tag & JS string String none setter
 

One of "lazy", "resize", "pooling", "none".


defaultselection Tag & JS number Number null setter
 

The number of the item that is initially selected. This overrides the value defined in the defaulttext attribute


defaulttext Tag & JS string String   setter
 

The text that appears in the text field when no item is selected.


editable Tag & JS expression any true setter
 

Make the text field of this combobox editable.


isopen Tag & JS expression any false setter
 

Indicates whether or not the popup list is showing.


itemclassname Tag & JS string String   setter
 

The class that is used to create an item in the list when itemdatapath is assigned.


min_width Tag & JS number Number 50 defaultsetter
 

The minimum width this component is allowed to be. Defaults to 50 pixels.


selected Tag & JS expression any null setter
 

The initial selected item.


shownitems Tag & JS expression any -1 setter
 

Sets the height of the combobox to show 'n' items.


spacing Tag & JS expression any 0 setter
 

The spacing size ( in pixels ) between items in the pop-up list.


text_width Tag & JS number Number   setter
 

the width the text. default: combowidth - 19


text_x Tag & JS number Number 2 setter
 

the x position of the text. default: 2


text_y Tag & JS number Number 2 setter
 

the y position of the text. default: 2



Attributes inherited from Basecomponent

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

Attributes inherited from Baseformitem

changed, ignoreform, 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

addItem()
basecombobox.addItem(txt, val)

Add the specified item to list to the end of the list.

Parameters
Name Type Desc
txt String the text for the item.
val Object the value for the item.


clearSelection()
basecombobox.clearSelection()

Clear the current selection in the list and sets the displayed text to an empty string



getItem()
basecombobox.getItem(value)

Find a particular item by value. This method is not available with dataoption="lazy" or dataoption="resize" (use data APIs instead).

Parameters
Name Type Desc
value Object the value for the item to get.
Returns
Type Desc
Object the item found, or null, if not.


getItemAt()
basecombobox.getItemAt(index)

Find a particular item by its index. This method not available with dataoption="lazy" or dataoption="resize" (use data APIs instead).

Parameters
Name Type Desc
index Number the index for the item to get.
Returns
Type Desc
Object the item found, or null, if not.


getSelection()
basecombobox.getSelection()

Returns current selection.

Returns
Type Desc
Object null if no selection, an item if single select (default), or an array of items if multiselect.


getText()
basecombobox.getText()

Get the displayed text.

Returns
Type Desc
String the displayed text.


getValue()
basecombobox.getValue()

Get the value for the combobox.

Returns
Type Desc
Object the value selected or the value in the text field, if no value was found.


removeItem()
basecombobox.removeItem(value)

Find the first item with the specified value and remove it from the list.

Parameters
Name Type Desc
value Object the value of the item to remove.


removeItemAt()
basecombobox.removeItemAt(index)

Remove an item by index (0 based count). This method is not available with dataoption="lazy" or dataoption="resize" (use data APIs instead).

Parameters
Name Type Desc
index Number the index of the item to remove.


select()
basecombobox.select(item)

Selects a specific item in the list.

Parameters
Name Type Desc
item Object the item to select.


selectItem()
basecombobox.selectItem(value)

Select an item by value. This method is not available with dataoption="lazy" or dataoption="resize".

Parameters
Name Type Desc
value Object the value of the item to select.


selectItemAt()
basecombobox.selectItemAt(index)

Select an item by index (0 based count).

Parameters
Name Type Desc
index Number the index of the item to select.


setDefaultSelection()
basecombobox.setDefaultSelection(ds)

Sets the number of the item that is initially selected. This overrides the value defined in the defaulttext attribute.

Parameters
Name Type Desc
ds Number the number of items to initally select.


setItemclassname()
basecombobox.setItemclassname(icn)

Sets the type of list items which will be created in floatinglist when necessary.

Parameters
Name Type Desc
icn String the class name to use to create items with.


setOpen()
basecombobox.setOpen(open, withkey)

Sets the open/close state of the popup list.

Parameters
Name Type Desc
open Boolean true to open the list, else false to close.
withkey Boolean (optional) if true this is triggered by keyboard and focus indicators will be turned on; if false, this is triggered by mouse action and focus indicators will be turned off; if parameter is ommitted no change in focus indicator


setText()
basecombobox.setText(t)

Sets the displayed text.

Parameters
Name Type Desc
t String the text to display.


setWidth()
basecombobox.setWidth(w)
Parameters
Name Type Desc
w None


toggle()
basecombobox.toggle(withkey)

Toggles the open/close state of the popup list.

Parameters
Name Type Desc
withkey Boolean (optional) if true this is triggered by keyboard and focus indicators will be turned on; if false, this is triggered by mouse action and focus indicators will be turned off; if parameter is ommitted no change in focus indicator


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 basevaluecomponent

getValue

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, setWidth, setX, setY, shouldYieldFocus, stop, stretchResource, unload, updateResourceSize


Events
Name Description
onchanged None
ondefaultselection None
onvalue None

Events inherited from baseformitem

onchanged, onvalue

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