| Package | qnx.fuse.ui.listClasses |
| Class | public class DropDown |
| Inheritance | DropDown UIComponent flash.display.MovieClip |
| Implements | IDataViewer |
DropDown class provides drop down list functionality. When the user taps the drop down, the list
expands to provide options that a user can select from.
The following image shows a DropDown instance in the closed state:
The following image shows a DropDown instance in the open state, after a user has touched the control:
See also
| Property | Defined By | ||
|---|---|---|---|
| autoPositionList : Boolean
Automatically sets showListAbove based on where the DropDown is on the stage. | DropDown | ||
| dataProvider : IDataProvider
Gets or sets the DataProvider for the DropDown list. | DropDown | ||
| dropDownParent : DisplayObjectContainer
Gets or sets the property that determines the parent for the drop down list. | DropDown | ||
![]() | explicitHeight : Number [read-only] | UIComponent | |
![]() | explicitWidth : Number [read-only] | UIComponent | |
![]() | includeInLayout : Boolean
Specifies if the component should be included in it's parent containers layout. | UIComponent | |
| isOpen : Boolean [read-only]
Returns true if the list is open in the DropDown. | DropDown | ||
![]() | layoutData : Object
Returns the layout data for the object. | UIComponent | |
| listWidthOffset : Number
Gets or sets the drop down list width offset from the width of the button. | DropDown | ||
| listYOffset : Number
Gets or sets the drop down list y coordinate offset. | DropDown | ||
| measureContents : Boolean | DropDown | ||
![]() | minHeight : Number
Sets the minimum preferred height of the control. | UIComponent | |
![]() | minWidth : Number
Sets the minimum preferred width of the control. | UIComponent | |
| prompt : String
Gets or sets the prompt that appears in the drop down. | DropDown | ||
| rowCount : int
Gets or sets the number of visible rows in the drop down list. | DropDown | ||
| rowHeight : int
Gets or sets the row height for the drop down list. | DropDown | ||
| selectedIndex : int
Gets or sets the index of the currently selected item in the drop down. | DropDown | ||
| selectedItem : Object
Gets or sets the currently selected item. | DropDown | ||
| showListAbove : Boolean
Determines if the drop down list will expand above or below the drop down button. | DropDown | ||
| Method | Defined By | ||
|---|---|---|---|
DropDown()
Creates a new DropDown instance. | DropDown | ||
addItem(item:Object):void
Adds an item to the list. | DropDown | ||
addItemAt(item:Object, index:int):void
Adds an item to the list at the specified index. | DropDown | ||
addItemsAt(items:Array, index:int):void
Adds an array item at the specified index. | DropDown | ||
![]() | childChanged(resizedChild:DisplayObject = null):Boolean
Notifies the UIComponent that one or more of its children has changed in a manner
that may affect this object's layout. | UIComponent | |
close():void
Closes the list of the DropDown component if it is open. | DropDown | ||
![]() | destroy():void
Call this method when you want to have your object collected by the garbage collector. | UIComponent | |
getItemAt(index:int):Object
Returns the item in the DataProvider at the specified index. | DropDown | ||
![]() | getSizeOptions():int | UIComponent | |
![]() | invalidateDisplayList():void
Calling this method results in a call to the components validateDisplayList() method before the display list is rendered. | UIComponent | |
![]() | invalidateProperties():void
Calling this method results in a call to the components validateProperties() method before the display list is rendered. | UIComponent | |
![]() | measure(availableWidth:Number, availableHeight:Number):LayoutMeasurement | UIComponent | |
open():void
Opens the list of the DropDown component if it is closed. | DropDown | ||
removeAll():void
Removes all the items from the list. | DropDown | ||
removeItem(item:Object):void
Removes the item from the list. | DropDown | ||
removeItemAt(index:int):void
Removes an item from list at the specified index. | DropDown | ||
replaceItem(item:Object, oldObject:Object):void
Replaces an item, given the new item object and the old item. | DropDown | ||
replaceItemAt(item:Object, index:int):void
Replaces the item in the list at the specified index, given the new item. | DropDown | ||
setAboveBackgroundSkin(skin:Object):void
Sets the skin for the List background. | DropDown | ||
setAboveButtonSkin(skin:Object):void
Sets the skin for the drop down button when list expands upward. | DropDown | ||
setAboveListSkin(skin:Object):void
Sets the CellRenderer for the List when list expands upward. | DropDown | ||
![]() | setActualSize(w:Number, h:Number):void
Sets the width and height of the object without setting
the explicitWidth and explicitHeight. | UIComponent | |
setBackgroundSkin(skin:Object):void
Sets the skin for the List background. | DropDown | ||
setButtonSkin(skin:Object):void
Sets the skin for the drop down button. | DropDown | ||
![]() | setLayoutBounds(bounds:Rectangle):void
Sets the receiver's size and location to the rectangular area specified
by the arguments. | UIComponent | |
setListSkin(skin:Object):void
Sets the CellRenderer for the List. | DropDown | ||
![]() | setPosition(x:Number, y:Number):void
Sets the x and y position of the component. | UIComponent | |
updateItem(value:Object, oldObject:Object):void
Updates the item in the list. | DropDown | ||
updateItemAt(item:Object, index:int):void
Updates the item in the list at the specified index. | DropDown | ||
updateItemsAt(items:Array, index:int):void
Updates the items starting at the specified index with new items. | DropDown | ||
![]() | validateDisplayList():void
Validates the display list of the component by calling the updateDisplayList(). | UIComponent | |
![]() | validateNow():void
Validates the component immediately by calling validateProperties(), validateSizes(), and validateDisplayList() if necessary. | UIComponent | |
![]() | validateProperties():void
Validates the properties of the component by calling the commitProperties() method. | UIComponent | |
| Event | Summary | Defined By | ||
|---|---|---|---|---|
| Dispatched when the drop down list is closed. | DropDown | |||
| Dispatched when the drop down list is opened. | DropDown | |||
| Dispatched when an item in the drop down list is selected. | DropDown | |||
| autoPositionList | property |
autoPositionList:BooleanAutomatically sets showListAbove based on where the DropDown is on the stage. If when the DropDown opens the list will be clipped by the stage edge, showListAbove is toggled.
public function get autoPositionList():Boolean public function set autoPositionList(value:Boolean):void| dataProvider | property |
dataProvider:IDataProvider
Gets or sets the DataProvider for the DropDown list.
public function get dataProvider():IDataProvider public function set dataProvider(value:IDataProvider):voidSee also
| dropDownParent | property |
dropDownParent:DisplayObjectContainerGets or sets the property that determines the parent for the drop down list.
The default value is the DropDown component itself.
public function get dropDownParent():DisplayObjectContainer public function set dropDownParent(value:DisplayObjectContainer):void| isOpen | property |
isOpen:Boolean [read-only] Returns true if the list is open in the DropDown.
The default value is false.
public function get isOpen():Boolean| listWidthOffset | property |
listWidthOffset:NumberGets or sets the drop down list width offset from the width of the button.
The drop down width (in pixels) offset from the width of the button. A positive value would make the drop-down list wider than the drop-down button. A negative value would make the drop-down list narrower than the drop-down button.
public function get listWidthOffset():Number public function set listWidthOffset(value:Number):void| listYOffset | property |
listYOffset:NumberGets or sets the drop down list y coordinate offset. The offset determines the position of the open list relative to the button.
public function get listYOffset():Number public function set listYOffset(value:Number):void| measureContents | property |
measureContents:Boolean public function get measureContents():Boolean public function set measureContents(value:Boolean):void| prompt | property |
prompt:StringGets or sets the prompt that appears in the drop down.
The prompt is shown as the default message in the drop down when the
selectedIndex value is set to -1. For example, the String "Select an item" prompts the user to select an item from the
drop down list. If no prompt is set, the selectedIndex value is set to 0 and the first item in the DataProvider is displayed in the
drop down.
public function get prompt():String public function set prompt(value:String):void| rowCount | property |
rowCount:intGets or sets the number of visible rows in the drop down list.
public function get rowCount():int public function set rowCount(value:int):void| rowHeight | property |
rowHeight:intGets or sets the row height for the drop down list.
The row height represents ths height of each item in the list (in pixels).
public function get rowHeight():int public function set rowHeight(value:int):void| selectedIndex | property |
selectedIndex:intGets or sets the index of the currently selected item in the drop down.
public function get selectedIndex():int public function set selectedIndex(value:int):void| selectedItem | property |
selectedItem:ObjectGets or sets the currently selected item.
In the included example, an event listener calls the function below to return information about the currently selected cell:
private function onSelect(event:Event):void {
trace("selected index: " + event.target.selectedIndex);
var myObj:Object = new Object();
myObj = event.target.selectedItem;
trace("Selected Item: " + myObj.label);
}
public function get selectedItem():Object public function set selectedItem(value:Object):void| showListAbove | property |
showListAbove:BooleanDetermines if the drop down list will expand above or below the drop down button.
In the following image, the drop down list expands above the drop down button (the showListAbove property is set to true):
public function get showListAbove():Boolean public function set showListAbove(value:Boolean):void| DropDown | () | Constructor |
public function DropDown()
Creates a new DropDown instance.
| addItem | () | method |
public function addItem(item:Object):voidAdds an item to the list.
Parameters
item:Object — The item to add.
|
RangeError — thrown if the specified index is less than 0 or greater than or equal to the length of the DataProvider.
|
| addItemAt | () | method |
public function addItemAt(item:Object, index:int):voidAdds an item to the list at the specified index.
Parameters
item:Object — The item to add.
| |
index:int — The index, or offset at which to add the item.
|
RangeError — thrown if the specified index is less than 0 or greater than or equal to the length of the DataProvider.
|
| addItemsAt | () | method |
public function addItemsAt(items:Array, index:int):voidAdds an array item at the specified index.
Parameters
items:Array — The array of items to add.
| |
index:int — The index, or offset, at which to add the items.
|
RangeError — Thrown if the specified index is less than 0, or greater than or equal to the length of the data provider.
|
See also
| close | () | method |
public function close():void
Closes the list of the DropDown component if it is open.
Calling this method will not fire a Event.CLOSE event.
| getItemAt | () | method |
public function getItemAt(index:int):Object
Returns the item in the DataProvider at the specified index.
Parameters
index:int — The index of the item to return.
|
Object — The item at the specified index.
|
RangeError — thrown if the specified index is less than 0 or greater than or equal to the length of the DataProvider.
|
| open | () | method |
public function open():void
Opens the list of the DropDown component if it is closed.
Calling this method will not fire a Event.OPEN event.
| removeAll | () | method |
public function removeAll():voidRemoves all the items from the list.
| removeItem | () | method |
public function removeItem(item:Object):voidRemoves the item from the list.
Parameters
item:Object — The item to remove.
|
ArgumentError — thrown if the item could not be found in the current DataProvider.
|
| removeItemAt | () | method |
public function removeItemAt(index:int):voidRemoves an item from list at the specified index.
Parameters
index:int — The index of the object to remove.
|
RangeError — thrown if the specified index is less than 0 or greater than or equal to the length of the DataProvider.
|
| replaceItem | () | method |
public function replaceItem(item:Object, oldObject:Object):voidReplaces an item, given the new item object and the old item.
Parameters
item:Object — The new item object data.
| |
oldObject:Object — The item to replace.
|
| replaceItemAt | () | method |
public function replaceItemAt(item:Object, index:int):voidReplaces the item in the list at the specified index, given the new item.
Parameters
item:Object — The new item.
| |
index:int — The index of the item to replace.
|
RangeError — thrown if the specified index is less than 0 or greater than or equal to the length of the DataProvider.
|
| setAboveBackgroundSkin | () | method |
public function setAboveBackgroundSkin(skin:Object):void
Sets the skin for the List background.
This method takes a DisplayObject class.
var myDDList:DropDown = new DropDown();
myDDList.setPosition(100, 500);
myDDList.width = 195;
myDDList.showListAbove = true;
myDDList.setAboveBackgroundSkin(DropDownBackgroundSkinBlack);
myDDList.prompt = "Intramurals";
You can pass in a qualified class name String, or the actual class.
In either instance the class that is used must implement the ICellRenderer interface.
Parameters
skin:Object — The List background skin.
|
| setAboveButtonSkin | () | method |
public function setAboveButtonSkin(skin:Object):voidSets the skin for the drop down button when list expands upward.
You can pass in a qualified class name String, or the actual class.
In either instance the class that is used must implement the ISkin interface.
Note: Do not pass in an instance of a skin class. This may cause unexpected behavior.
Parameters
skin:Object — The button skin.
|
| setAboveListSkin | () | method |
public function setAboveListSkin(skin:Object):void
Sets the CellRenderer for the List when list expands upward.
By default, the DropDown class uses the CellRenderer class to render the cells in the list. In the example below, the
AlternatingCellRenderer class is passed in to the setListSkin method to provide alternating colors (grey and white) for the
adjacent cells in the list.
var myDDList:DropDown = new DropDown();
myDDList.setPosition(100, 400);
myDDList.width = 195;
myDDList.prompt = "Intramurals";
myDDList.showListAbove = true;
myDDList.setAboveListSkin(AlternatingCellRenderer);
You can pass in a qualified class name String, or the actual class.
In either instance the class that is used must implement the ICellRenderer interface.
Note: Do not pass in an instance of a skin class. This may cause unexpected behavior.
Parameters
skin:Object — The skin instance.
|
| setBackgroundSkin | () | method |
public function setBackgroundSkin(skin:Object):void
Sets the skin for the List background.
This method takes a DisplayObject class.
var myDDList:DropDown = new DropDown();
myDDList.setPosition(100, 200);
myDDList.width = 195;
myDDList.setBackgroundSkin(DropDownBackgroundSkinBlack);
myDDList.prompt = "Intramurals";
Parameters
skin:Object — The List background skin.
|
| setButtonSkin | () | method |
public function setButtonSkin(skin:Object):voidSets the skin for the drop down button.
You can pass in a qualified class name String, or the actual class.
In either instance the class that is used must implement the ISkin interface.
Note: Do not pass in an instance of a skin class. This may cause unexpected behavior.
Parameters
skin:Object — The button skin.
|
| setListSkin | () | method |
public function setListSkin(skin:Object):void
Sets the CellRenderer for the List.
By default, the DropDown class uses the CellRenderer class to render the cells in the list. In the example below, the
AlternatingCellRenderer class is passed in to the setListSkin method to provide alternating colors (grey and white) for the
adjacent cells in the list.
var myDDList:DropDown = new DropDown();
myDDList.setPosition(100, 400);
myDDList.prompt = "Intramurals";
myDDList.showListAbove = true;
myDDList.setListSkin(DropDownCellRendererSkin);
You can pass in a qualified class name String, or the actual class.
In either instance the class that is used must implement the ICellRenderer interface.
Note: Do not pass in an instance of a skin class. This may cause unexpected behavior.
Parameters
skin:Object — The skin instance.
|
| updateItem | () | method |
public function updateItem(value:Object, oldObject:Object):voidUpdates the item in the list.
Parameters
value:Object — The item to update.
| |
oldObject:Object — old item, or the item to update.
|
| updateItemAt | () | method |
public function updateItemAt(item:Object, index:int):voidUpdates the item in the list at the specified index.
Parameters
item:Object — The updated item.
| |
index:int — The index of the item to update.
|
RangeError — thrown if the specified index is less than 0 or greater than or equal to the length of the DataProvider.
|
| updateItemsAt | () | method |
public function updateItemsAt(items:Array, index:int):voidUpdates the items starting at the specified index with new items.
Parameters
items:Array — The new items to be updated.
| |
index:int — The start index to update the items
|
RangeError — Thrown if the specified index is less than 0, or greater than or equal to the length of the DataProvider.
|
See also
| close | Event |
flash.events.Eventflash.events.Event.CLOSEDispatched when the drop down list is closed.
| open | Event |
flash.events.Eventflash.events.Event.OPENDispatched when the drop down list is opened.
| select | Event |
flash.events.Eventflash.events.Event.SELECTDispatched when an item in the drop down list is selected.
The following example creates a simple DropDown instance. The dropdown uses event listeners to capture
user interaction.
package
{
import flash.display.Sprite;
import flash.events.Event;
import qnx.ui.data.DataProvider;
import qnx.ui.listClasses.DropDown;
import qnx.fuse.ui.listClasses.DropDown;
[SWF(height="600", width="1024",
frameRate="30", backgroundColor="#FFFFFF")]
frameRate="30", backgroundColor="#FFFFFF")]
public class MyDropDownExample extends Sprite
{
public function MyDropDownExample()
{
initializeUI();
}
private function initializeUI():void
{
var arrMonth:Array=[];
// add objects with a label property
arrMonth.push({label: "Hockey"});
arrMonth.push({label: "Baseball"});
arrMonth.push({label: "Football"});
arrMonth.push({label: "Golf"});
arrMonth.push({label: "Basketball"});
var myDDList:DropDown = new DropDown();
myDDList.setPosition(100, 100);
var myDDList:DropDown = new DropDown();
myDDList.setPosition(100, 100);
myDDList.width = 195;
myDDList.prompt = "Intramurals";
//set the dataProvider
myDDList.dataProvider = new DataProvider(arrMonth);
myDDList.addEventListener(Event.SELECT, onSelect);
this.addChild(myDDList);
}
private function onSelect(event:Event):void {
trace("selected index: " + event.target.selectedIndex);
var myObj:Object = new Object();
myObj = event.target.selectedItem;
trace("Selected Item: " + myObj.label);
}
}
}