Name

basedatacombobox — baseclass for a datacombobox

Synopsis

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

Description

An abstract class to create dropdown lists of selectable items. Define the look in a subclass. Also, a basedatacombobox_text must be declared in the subclass.
              <class name="simplecombobox" extends="basedatacombobox" width="100">
                  <attribute name="_cbtext" value="$once{this._text}"/>
                  <view width="100%" height="20" focusable="false" bgcolor="#CCCCCC">
                      <handler name="onclick">
                          LzFocus.setFocus(this,false); 
                          classroot.toggle()
                      </handler>
                      <handler name="onmouseout">
                          this.setBGColor(0xCCCCCC);
                      </handler>
                      <handler name="onmouseup">
                          this.setBGColor(0xCCCCCC);
                      </handler>
                      <handler name="onmouseover">
                          this.setBGColor(0xEEEEEE);
                      </handler>
                      <handler name="onmousedown">
                          this.setBGColor(0xAAAAAA);
                      </handler>
                  </view>
                  <text name="_text" width="${ parent.width - 19 }" x="7" />
              </class>
              
** Caveat: Combobox items will not update if the attributes that are mapped to textdatapath or valuedatapath change. To force the changes to update, call node.parentNode.replaceChild(node.cloneNode(true), node) where node is the dataelement of the list item. Don't forget to reset the seleciton on the list, as well.

Superclass Chain

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

Known Subclasses

Known Direct Subclasses: datacombobox

Details

Properties (15)

defaulttext
<attribute name="defaulttext" type="string" value="$once{null}" />
public var defaulttext : String;
Default text to display before a selection is made. No default item is selected if defaulttext is set. Defaulttext is replaced with selected item's text.
ismenu
<attribute name="ismenu" value="false" />
public var ismenu;
If true, the combobox will behave like a menu. "value" is ignored, and items will not remain selected. Selecting an item generates an onselect event
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 name of the class for items in the floating list.
itemdatapath
<attribute name="itemdatapath" type="string" value="null" />
public var itemdatapath : String;
Datapath to items in list.
listattach
<attribute name="listattach" type="string" value="bottom" />
public var listattach : String;
Where the floatinglist should attach to its owner. Possible values: bottom, top, left, right. In the event of a canvas out-of-bounds, the floating list will attach in a visible location. default: bottom
listwidth
<attribute name="listwidth" value="null" />
public var listwidth;
Width of popup list, defaults to width of combobox view. During setup, the width of the floating list view might not yet be set, so this returns the expected width. If not set,
menuclassname
<attribute name="menuclassname" type="string" value="" />
public var menuclassname : String;
selected
<attribute name="selected" value="null" />
public read-only var selected;
Datapointer to selected item.
selectfirst
<attribute name="selectfirst" value="true" />
public var selectfirst;
When true, the 1st item is selected oninit.
shownitems
<attribute name="shownitems" value="4" />
public var shownitems;
Sets the height to the number of items to show in combobox popup list. Default is 4, must be greater than 0.
statictext
<attribute name="statictext" type="string" value="$once{null}" />
public var statictext : String;
If set, this will always be displayed instead of selected item text. Behaves like a menu button. Also see defaulttext.
textdatapath
<attribute name="textdatapath" type="string" value="text()" />
public var textdatapath : String;
Datapath to text to display for items in list. See caveat.
value
<attribute name="value" value="null" />
public var value;
The value of the selected item.
valuedatapath
<attribute name="valuedatapath" type="string" value="@value" />
public var valuedatapath : String;
Datapath to value for items in list. See caveat.

Methods (8)

getItemIndex()
<method name="getItemIndex" args="value" />
public function getItemIndex(value : Object);
Get item's index by value. Note: If you have a stray character in dataset, this will break. CDATA is included in nodes.length.
getValue()
<method name="getValue" />
public function getValue();
Override getValue because we don't want to return this.text if this.value is null (this.text may be the defaulttext)
selectItem()
<method name="selectItem" args="value" />
public function selectItem(value : Object);
Select an item by value.
selectItemAt()
<method name="selectItemAt" args="index" />
public function selectItemAt(index : Number);
Select an item by index.
setChanged()
<method name="setChanged" args="isChanged" />
public function setChanged(isChanged : Boolean);
Setter to set baseformitem to changed. Should be called by subclasses whenever a value is set. The first time this is called, the changed value is not set since it assumes subclasses are setting their initial value. This also updates the selected value in the combobox to reflect the new value (in case it was changed).
setOpen()
<method name="setOpen" args="open" />
public function setOpen(open : Boolean);
Sets the open/close state of the popup list.
setValue()
<method name="setValue" args="value, isinitvalue, ignoreselection" />
public function setValue(value, isinitvalue : Boolean, ignoreselection);
Set value of combobox.
toggle()
<method name="toggle" />
public function toggle();
Toggles the open/close state of the popup list.

Events (5)

oncomboblur
<attribute name="oncomboblur" />
public event oncomboblur;
The equivalent for onblur for combobox.
oncombofocus
<attribute name="oncombofocus" />
public event oncombofocus;
The equivalent for onfocus for combobox.
onisopen
<attribute name="onisopen" />
public event onisopen;
Called when combobox opens or closes
onselect
<attribute name="onselect" />
public event onselect;
Event sent when an item is selected. Sends selected item.
onselected
<attribute name="onselected" />
public event onselected;
Event sent when an item is selected. Sends selected item.

LZX Synopsis

<class name="basedatacombobox" extends=" baseformitem ">
  <attribute name=" defaulttext " type="string" value="$once{null}" />
  <attribute name=" ismenu " value="false" />
  <attribute name=" isopen " value="false" />
  <attribute name=" itemclassname " type="string" value="" />
  <attribute name=" itemdatapath " type="string" value="null" />
  <attribute name=" listattach " type="string" value="bottom" />
  <attribute name=" listwidth " value="null" />
  <attribute name=" menuclassname " type="string" value="" />
  <attribute name=" selected " value="null" />
  <attribute name=" selectfirst " value="true" />
  <attribute name=" shownitems " value="4" />
  <attribute name=" statictext " type="string" value="$once{null}" />
  <attribute name=" textdatapath " type="string" value="text()" />
  <attribute name=" value " value="null" />
  <attribute name=" valuedatapath " type="string" value="@value" />
  <method name=" getItemIndex " args="value" />
  <method name=" getValue " />
  <event name=" oncomboblur " />
  <event name=" oncombofocus " />
  <event name=" onisopen " />
  <event name=" onselect " />
  <event name=" onselected " />
  <method name=" selectItem " args="value" />
  <method name=" selectItemAt " args="index" />
  <method name=" setChanged " args="isChanged" />
  <method name=" setOpen " args="open" />
  <method name=" setValue " args="value, isinitvalue, ignoreselection" />
  <method name=" toggle " />
</class>

JavaScript Synopsis

public basedatacombobox extends  baseformitem  {
  public var defaulttext  : String;
  public var ismenu ;
  public var isopen ;
  public var itemclassname  : String;
  public var itemdatapath  : String;
  public var listattach  : String;
  public var listwidth ;
  public var menuclassname  : String;
  public read-only var selected ;
  public var selectfirst ;
  public var shownitems ;
  public var statictext  : String;
  public var textdatapath  : String;
  public var value ;
  public var valuedatapath  : String;
  prototype public function getItemIndex (value : Object);
  prototype public function getValue ();
  prototype public event oncomboblur ;
  prototype public event oncombofocus ;
  prototype public event onisopen ;
  prototype public event onselect ;
  prototype public event onselected ;
  prototype public function selectItem (value : Object);
  prototype public function selectItemAt (index : Number);
  prototype public function setChanged (isChanged : Boolean);
  prototype public function setOpen (open : Boolean);
  prototype public function setValue (value, isinitvalue : Boolean, ignoreselection);
  prototype public function toggle ();
}