Name

basecombobox — baseclass for a combobox

Synopsis

LZX: basecombobox
JavaScript: lz.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

Details

Properties (21)

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".
defaultplacement
<attribute name="defaultplacement" type="string" value="cblist" />
private var defaultplacement : String;
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.
_fixseldel
<attribute name="_fixseldel" value="$once{new LzDelegate(this, 'fixSelection')}" />
private var _fixseldel;
initcomplete
<attribute name="initcomplete" value="0" />
private var initcomplete;
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.
mousedownintext
<attribute name="mousedownintext" value="false" />
private var mousedownintext;
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 (29)

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.
applyData()
<method name="applyData" args="d" />
private function applyData(d);
_applystyle()
<method name="_applystyle" args="s" />
private function _applystyle(s);
clearSelection()
<method name="clearSelection" />
public function clearSelection();
Clear the current selection in the list and sets the displayed text to an empty string
determinePlacement()
<method name="determinePlacement" args="newsub, placement, iargs" />
private function determinePlacement(newsub, placement, iargs);
fixSelection()
<method name="fixSelection" />
private function fixSelection();
getFocusRect()
<method name="getFocusRect" />
private function getFocusRect();
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).
getNextSelection()
<method name="getNextSelection" />
private function getNextSelection();
Since we are not focusable, defer to the inputtext's next selection, so that when floatinglist is tabbed out of, we can provide a next selection since we are it's owner
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.
init()
<method name="init" />
private function init();
passModeEvent()
<method name="passModeEvent" args="eventStr, view" />
private function passModeEvent(eventStr, view);
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).
resolveSelection()
<method name="resolveSelection" />
private function resolveSelection();
since we are not focusable, this provides an api for asking what child to send focus to, as is the case when floatinglist is shift-tabbed back to us.
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.
setEditable()
<method name="setEditable" args="isEditable" />
private function setEditable(isEditable);
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);
_showEnabled()
<method name="_showEnabled" />
private function _showEnabled();
toggle()
<method name="toggle" args="withkey" />
public function toggle(withkey : Boolean);
Toggles the open/close state of the popup list.

Events (5)

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

LZX Synopsis

<class name="lz.basecombobox" extends=" lz.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=" defaultplacement " type="string" value="cblist" />
  <attribute name=" defaultselection " type="number" value="null" />
  <attribute name=" defaulttext " type="string" value="" />
  <attribute name=" editable " value="true" />
  <attribute name=" _fixseldel " value="$once{new LzDelegate(this, 'fixSelection')}" />
  <attribute name=" initcomplete " value="0" />
  <attribute name=" isopen " value="false" />
  <attribute name=" itemclassname " type="string" value="" />
  <attribute name=" min_width " type="number" value="50" />
  <attribute name=" mousedownintext " value="false" />
  <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=" applyData " args="d" />
  <method name=" _applystyle " args="s" />
  <method name=" clearSelection " />
  <method name=" determinePlacement " args="newsub, placement, iargs" />
  <method name=" fixSelection " />
  <method name=" getFocusRect " />
  <method name=" getItem " args="value" />
  <method name=" getItemAt " args="index" />
  <method name=" getNextSelection " />
  <method name=" getSelection " />
  <method name=" getText " />
  <method name=" getValue " />
  <method name=" init " />
  <event name=" ondefaultselection " />
  <event name=" oneditable " />
  <event name=" onitemclassname " />
  <event name=" onselect " />
  <event name=" ontext " />
  <method name=" passModeEvent " args="eventStr, view" />
  <method name=" removeItem " args="value" />
  <method name=" removeItemAt " args="index" />
  <method name=" resolveSelection " />
  <method name=" select " args="item" />
  <method name=" selectItem " args="value" />
  <method name=" selectItemAt " args="index" />
  <method name=" setDefaultSelection " args="ds" />
  <method name=" setEditable " args="isEditable" />
  <method name=" setItemclassname " args="icn" />
  <method name=" setOpen " args="open, withkey" />
  <method name=" setText " args="t" />
  <method name=" setWidth " args="w" />
  <method name=" _showEnabled " />
  <method name=" toggle " args="withkey" />
</class>

JavaScript Synopsis

public lz.basecombobox extends  lz.baseformitem  {
  public var attachoffset  : Number;
  public var autoscrollbar ;
  public var bordersize ;
  public var dataoption  : String;
  private var defaultplacement  : String;
  public var defaultselection  : Number;
  public var defaulttext  : String;
  public var editable ;
  private var _fixseldel ;
  private var initcomplete ;
  public var isopen ;
  public var itemclassname  : String;
  public var min_width  : Number;
  private var mousedownintext ;
  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 private function applyData (d);
  prototype private function _applystyle (s);
  prototype public function clearSelection ();
  prototype private function determinePlacement (newsub, placement, iargs);
  prototype private function fixSelection ();
  prototype private function getFocusRect ();
  prototype public function getItem (value : Object) : Object;
  prototype public function getItemAt (index : Number) : Object;
  prototype private function getNextSelection ();
  prototype public function getSelection () : Object;
  prototype public function getText () : String;
  prototype public function getValue () : Object;
  prototype private function init ();
  prototype public event ondefaultselection ;
  prototype private event oneditable ;
  prototype private event onitemclassname ;
  prototype public event onselect ;
  prototype private event ontext ;
  prototype private function passModeEvent (eventStr, view);
  prototype public function removeItem (value : Object);
  prototype public function removeItemAt (index : Number);
  prototype private function resolveSelection ();
  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 private function setEditable (isEditable);
  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 private function _showEnabled ();
  prototype public function toggle (withkey : Boolean);
}