<basecombobox>
baseclass for a combobox

JavaScript: lz.basecombobox

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 36. custom appearance and font for a combobox

<canvas 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> .

A dropdown list of selectable items. Can either be editable or not.

Attributes

Name (CSS property) Type (tag) Type (js) Default Category
attachoffset number Number -1 read/write
  The vertical offset of the floatinglist attached to this combobox.
autoscrollbar expression any true read/write
  Whether a scrollbar should automatically show up when there are more items than shownitems.
bordersize expression any 1 read/write
  The border size ( in pixels ) of the popup list.
dataoption string String none read/write
  One of "lazy", "resize", "pooling", "none".
defaultselection number Number null read/write
  The number of the item that is initially selected. This overrides the value defined in the defaulttext attribute
defaulttext string String   read/write
  The text that appears in the text field when no item is selected.
editable expression any true read/write
  Make the text field of this combobox editable.
isopen expression any false read/write
  Indicates whether or not the popup list is showing.
itemclassname string String   read/write
  The class that is used to create an item in the list.
min_width number Number 50 read/write
  The minimum width this component is allowed to be.
selected expression any null read/write
  The initial selected item.
shownitems expression any -1 read/write
  Sets the height of the combobox to show 'n' items.
spacing expression any 0 read/write
  The spacing size ( in pixels ) between items in the pop-up list.
text_width number Number this.width - 19 read/write
  the width the text.
text_x number Number 2 read/write
  the x position of the text.
text_y number Number 2 read/write
  the y position of the text.
value expression any cblist.value read/write
  The value of the combobox.

Attributes inherited from <basevaluecomponent>

type, value

Methods

addItem()
basecombobox.addItem(txt : String, val : Object);
Add the specified item to list to the end of the list.
Parameter Name Type Description
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 : Object);
Find a particular item by value. This method is not available with dataoption="lazy" or dataoption="resize" (use data APIs instead).
Parameter Name Type Description
value Object the value for the item to get.
Returns Type Description
  Object the item found, or null, if not.

getItemAt()
basecombobox.getItemAt(index : Number);
Find a particular item by its index. This method not available with dataoption="lazy" or dataoption="resize" (use data APIs instead).
Parameter Name Type Description
index Number the index for the item to get.
Returns Type Description
  Object the item found, or null, if not.

getSelection()
basecombobox.getSelection();
Returns current selection.
Returns Type Description
  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 Description
  String the displayed text.

getValue()
basecombobox.getValue();
Get the value for the combobox.
Returns Type Description
  Object the value selected or the value in the text field, if no value was found.

removeItem()
basecombobox.removeItem(value : Object);
Find the first item with the specified value and remove it from the list.
Parameter Name Type Description
value Object the value of the item to remove.

removeItemAt()
basecombobox.removeItemAt(index : Number);
Remove an item by index (0 based count). This method is not available with dataoption="lazy" or dataoption="resize" (use data APIs instead).
Parameter Name Type Description
index Number the index of the item to remove.

select()
basecombobox.select(item : Object);
Selects a specific item in the list.
Parameter Name Type Description
item Object the item to select.

selectItem()
basecombobox.selectItem(value : Object);
Select an item by value. This method is not available with dataoption="lazy" or dataoption="resize".
Parameter Name Type Description
value Object the value of the item to select.

selectItemAt()
basecombobox.selectItemAt(index : Number);
Select an item by index (0 based count).
Parameter Name Type Description
index Number the index of the item to select.

setDefaultSelection()
basecombobox.setDefaultSelection(ds : Number);
Sets the number of the item that is initially selected. This overrides the value defined in the defaulttext attribute.
Parameter Name Type Description
ds Number the number of items to initally select.

setItemclassname()
basecombobox.setItemclassname(icn : String);
Sets the type of list items which will be created in floatinglist when necessary.
Parameter Name Type Description
icn String the class name to use to create items with.

setOpen()
basecombobox.setOpen(open : Boolean, withkey : Boolean);
Sets the open/close state of the popup list.
Parameter Name Type Description
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 : String);
Sets the displayed text. (This isn't an override from LzText)
Parameter Name Type Description
t String the text to display.

toggle()
basecombobox.toggle(withkey : Boolean);
Toggles the open/close state of the popup list.
Parameter Name Type Description
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 lz.Eventable

destroy, setAttribute

Events

Name Description
ondefaultselection This event is sent when the default selection is set.
onselect This event is triggered whenever the user makes a selection. It may be used as a script in the combobox tag or as an event method.

Events inherited from <baseformitem>

onchanged, onvalue

Events inherited from <node>

onconstruct, ondata, oninit

Events inherited from lz.Eventable

ondestroy