Name

basecombobox — baseclass for a combobox

Synopsis

LZX: basecombobox
JavaScript: basecombobox
Type: Class
Access: public
Topic: Components.Base Components
Declared in: lps/components/base/basecombobox.lzx

Description

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

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

Superclass Chain

node (LzNode) » view (LzView) » basecomponent » basevaluecomponent » baseformitem » basecombobox

Known Subclasses

Known Direct Subclasses: combobox

Details

Properties (17)

attachoffset
<attribute name="attachoffset" type="number" value="-1" />
public var attachoffset : Number;
The vertical offset of the floatinglist attached to this combobox.
autoscrollbar
<attribute name="autoscrollbar" value="true" />
public var autoscrollbar;
Whether a scrollbar should automatically show up when there are more items than shownitems.
bordersize
<attribute name="bordersize" value="1" />
public var bordersize;
The border size ( in pixels ) of the popup list.
dataoption
<attribute name="dataoption" type="string" value="none" />
public var dataoption : String;
One of "lazy", "resize", "pooling", "none".
defaultselection
<attribute name="defaultselection" type="number" value="null" />
public var defaultselection : Number;
The number of the item that is initially selected. This overrides the value defined in the defaulttext attribute
defaulttext
<attribute name="defaulttext" type="string" value="" />
public var defaulttext : String;
The text that appears in the text field when no item is selected.
editable
<attribute name="editable" value="true" />
public var editable;
Make the text field of this combobox editable.
isopen
<attribute name="isopen" value="false" />
public var isopen;
Indicates whether or not the popup list is showing.
itemclassname
<attribute name="itemclassname" type="string" value="" />
public var itemclassname : String;
The class that is used to create an item in the list when itemdatapath is assigned.
min_width
<attribute name="min_width" type="number" value="50" />
public var min_width : Number;
The minimum width this component is allowed to be. Defaults to 50 pixels.
selected
<attribute name="selected" value="null" />
public var selected;
The initial selected item.
shownitems
<attribute name="shownitems" value="-1" />
public var shownitems;
Sets the height of the combobox to show 'n' items.
spacing
<attribute name="spacing" value="0" />
public var spacing;
The spacing size ( in pixels ) between items in the pop-up list.
text_width
<attribute name="text_width" type="number" value="${this.width - 19}" />
public var text_width : Number;
the width the text. default: combowidth - 19
text_x
<attribute name="text_x" type="number" value="2" />
public var text_x : Number;
the x position of the text. default: 2
text_y
<attribute name="text_y" type="number" value="2" />
public var text_y : Number;
the y position of the text. default: 2
value
<attribute name="value" value="${cblist.value}" />
public var value;
The value of the combobox.

Methods (18)

addItem()
<method name="addItem" args="txt, val" />
public function addItem(txt : String, val : Object);
Add the specified item to list to the end of the list.
clearSelection()
<method name="clearSelection" />
public function clearSelection();
Clear the current selection in the list and sets the displayed text to an empty string
getItem()
<method name="getItem" args="value" />
public function getItem(value : Object) : Object;
Find a particular item by value. This method is not available with dataoption="lazy" or dataoption="resize" (use data APIs instead).
getItemAt()
<method name="getItemAt" args="index" />
public function getItemAt(index : Number) : Object;
Find a particular item by its index. This method not available with dataoption="lazy" or dataoption="resize" (use data APIs instead).
getSelection()
<method name="getSelection" />
public function getSelection() : Object;
Returns current selection.
getText()
<method name="getText" />
public function getText() : String;
Get the displayed text.
getValue()
<method name="getValue" />
public function getValue() : Object;
Get the value for the combobox.
removeItem()
<method name="removeItem" args="value" />
public function removeItem(value : Object);
Find the first item with the specified value and remove it from the list.
removeItemAt()
<method name="removeItemAt" args="index" />
public function 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).
select()
<method name="select" args="item" />
public function select(item : Object);
Selects a specific item in the list.
selectItem()
<method name="selectItem" args="value" />
public function selectItem(value : Object);
Select an item by value. This method is not available with dataoption="lazy" or dataoption="resize".
selectItemAt()
<method name="selectItemAt" args="index" />
public function selectItemAt(index : Number);
Select an item by index (0 based count).
setDefaultSelection()
<method name="setDefaultSelection" args="ds" />
public function setDefaultSelection(ds : Number);
Sets the number of the item that is initially selected. This overrides the value defined in the defaulttext attribute.
setItemclassname()
<method name="setItemclassname" args="icn" />
public function setItemclassname(icn : String);
Sets the type of list items which will be created in floatinglist when necessary.
setOpen()
<method name="setOpen" args="open, withkey" />
public function setOpen(open : Boolean, withkey : Boolean);
Sets the open/close state of the popup list.
setText()
<method name="setText" args="t" />
public function setText(t : String);
Sets the displayed text.
setWidth()
<method name="setWidth" args="w" />
public function setWidth(w);
toggle()
<method name="toggle" args="withkey" />
public function toggle(withkey : Boolean);
Toggles the open/close state of the popup list.

Events (2)

ondefaultselection
<attribute name="ondefaultselection" />
public event ondefaultselection;
This event is sent when the default selection is set.
onselect
<attribute name="onselect" />
public event 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.

LZX Synopsis

<class name="basecombobox" extends=" baseformitem ">
  <attribute name=" attachoffset " type="number" value="-1" />
  <attribute name=" autoscrollbar " value="true" />
  <attribute name=" bordersize " value="1" />
  <attribute name=" dataoption " type="string" value="none" />
  <attribute name=" defaultselection " type="number" value="null" />
  <attribute name=" defaulttext " type="string" value="" />
  <attribute name=" editable " value="true" />
  <attribute name=" isopen " value="false" />
  <attribute name=" itemclassname " type="string" value="" />
  <attribute name=" min_width " type="number" value="50" />
  <attribute name=" selected " value="null" />
  <attribute name=" shownitems " value="-1" />
  <attribute name=" spacing " value="0" />
  <attribute name=" text_width " type="number" value="${this.width - 19}" />
  <attribute name=" text_x " type="number" value="2" />
  <attribute name=" text_y " type="number" value="2" />
  <attribute name=" value " value="${cblist.value}" />
  <method name=" addItem " args="txt, val" />
  <method name=" clearSelection " />
  <method name=" getItem " args="value" />
  <method name=" getItemAt " args="index" />
  <method name=" getSelection " />
  <method name=" getText " />
  <method name=" getValue " />
  <event name=" ondefaultselection " />
  <event name=" onselect " />
  <method name=" removeItem " args="value" />
  <method name=" removeItemAt " args="index" />
  <method name=" select " args="item" />
  <method name=" selectItem " args="value" />
  <method name=" selectItemAt " args="index" />
  <method name=" setDefaultSelection " args="ds" />
  <method name=" setItemclassname " args="icn" />
  <method name=" setOpen " args="open, withkey" />
  <method name=" setText " args="t" />
  <method name=" setWidth " args="w" />
  <method name=" toggle " args="withkey" />
</class>

JavaScript Synopsis

public basecombobox extends  baseformitem  {
  public var attachoffset  : Number;
  public var autoscrollbar ;
  public var bordersize ;
  public var dataoption  : String;
  public var defaultselection  : Number;
  public var defaulttext  : String;
  public var editable ;
  public var isopen ;
  public var itemclassname  : String;
  public var min_width  : Number;
  public var selected ;
  public var shownitems ;
  public var spacing ;
  public var text_width  : Number;
  public var text_x  : Number;
  public var text_y  : Number;
  public var value ;
  prototype public function addItem (txt : String, val : Object);
  prototype public function clearSelection ();
  prototype public function getItem (value : Object) : Object;
  prototype public function getItemAt (index : Number) : Object;
  prototype public function getSelection () : Object;
  prototype public function getText () : String;
  prototype public function getValue () : Object;
  prototype public event ondefaultselection ;
  prototype public event onselect ;
  prototype public function removeItem (value : Object);
  prototype public function removeItemAt (index : Number);
  prototype public function select (item : Object);
  prototype public function selectItem (value : Object);
  prototype public function selectItemAt (index : Number);
  prototype public function setDefaultSelection (ds : Number);
  prototype public function setItemclassname (icn : String);
  prototype public function setOpen (open : Boolean, withkey : Boolean);
  prototype public function setText (t : String);
  prototype public function setWidth (w);
  prototype public function toggle (withkey : Boolean);
}