qnx.fuse.ui.listClasses.DropDown

DropDown

Properties | Methods | Events | Examples


Packageqnx.fuse.ui.listClasses
Classpublic class DropDown
InheritanceDropDown Inheritance ExpandableControl Inheritance UIComponent Inheritance flash.display.MovieClip
Implements IDataViewer

The 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:

A closed drop down list.

The following image shows a DropDown instance in the open state, after a user has touched the control:

An open drop down list.

Class information:
BlackBerry 10 Version:   10.0.0

View the examples

See also

DropDownCellRenderer



Public Properties

 PropertyDefined By
 InheritedanimationTime : Number
Gets or sets the time, in seconds, of the open and close animations.
ExpandableControl
 InheritedcontentPaddingBottom : Number
Gets or sets the bottom padding of the content.
ExpandableControl
 InheritedcontentPaddingLeft : Number
Gets or sets the left padding of the content.
ExpandableControl
 InheritedcontentPaddingRight : Number
Gets or sets the right padding of the content.
ExpandableControl
 InheritedcontentPaddingTop : Number
Gets or sets the top padding of the content.
ExpandableControl
 InheritedcontextActions : Vector.<ActionSet>
Gets or Sets a Vector of ActionSet objects.
UIComponent
 InheritedcontextMultiSelectText : String
Gets or Sets a String to be displayed when showing the Multi Select Context Menu.
UIComponent
 InheritedcurrentTheme : String
[read-only] Returns the current theme this component is styled with.
UIComponent
  dataProvider : IDataProvider
Gets or sets the DataProvider for the DropDown list.
DropDown
 InheritedexpandableDirection : String
Gets or sets the expand direction of the ExpandableControl.
ExpandableControl
 InheritedexpandedParent : DisplayObjectContainer
Gets or sets the property that determines the parent for the expanded content.
ExpandableControl
 InheritedexplicitHeight : Number
[read-only] Returns the explicit height (actual height, in pixels) of the UI component.
UIComponent
 InheritedexplicitWidth : Number
[read-only] Returns the explicit width (actual width, in pixels) of the UI component.
UIComponent
 Inheritedid : String
The id is a name for the component that can be used in CSS using the # selector.
UIComponent
 InheritedincludeInLayout : Boolean
Specifies whether or not the component should be included in its parent container's layout.
UIComponent
  isAlphabetical : Boolean
Deprecated: isAlphabetical has been deprecated. Optimizations surrounding alphabetical data for keyboard search have been internalized and as such this flag is no longer needed.
Gets or sets whether the contents of the DataProvider are in alphabetical order.
DropDown
 InheritedlayoutData : Object
Gets or sets the layoutData.
UIComponent
 Inheritedlocale : String
Gets or sets the current locale of the component.
UIComponent
 InheritedmaxExpandedHeight : Number
Gets or sets the maximum content height for the content that appears in the expandable area of the ExpandableControl.
ExpandableControl
  measureContents : Boolean
Gets or sets a flag that is used to determine whether the control is sized based on its content when it is in a layout.
DropDown
 InheritedminHeight : Number
Gets or sets the minimum preferred height of the control.
UIComponent
 InheritedminWidth : Number
Gets or sets the minimum preferred width of the control.
UIComponent
 Inheritedopen : Boolean
Gets or sets the open state of the ExpandableControl.
ExpandableControl
 Inheritedprompt : String
Gets or sets the label for the button.
ExpandableControl
  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
 InheritedstyleChildren : Boolean
Allows you to style the children of this component with CSS.
UIComponent
 Inheritedvalue : String
[read-only] Gets the value shown in the button.
ExpandableControl

Protected Properties

 PropertyDefined By
 InheritedaccessibilityImplimentationClass : Class
UIComponent
  cssID : String
[override] [read-only] Returns the CSS ID of the component.
DropDown
 InheritedexpandableContent : UIComponent
Gets or sets the content that appears in the expandable area of the ExpandableControl
ExpandableControl
 InheritedexplicitLocale : Boolean
Set to true when the locale property has been set externally.
UIComponent
 InheritedinternalID : String
The Component's Id used for styling.
UIComponent
 InheritedlongPressEnabled : Boolean
Specifies whether the UIComponent can detect a long press.
UIComponent

Public Methods

 MethodDefined By
  
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
 Inherited
Cancels a long press from occuring on the component.
UIComponent
 Inherited
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
 Inherited
destroy():void
Call this method when you want to have your object collected by the garbage collector.
UIComponent
 Inherited
Returns the CSS selector for the object, composing it from its position in the display hierarchy and an optional ID selector.
UIComponent
  
getItemAt(index:int):Object
Returns the item in the DataProvider at the specified index.
DropDown
 Inherited
Returns the size options for the given control.
UIComponent
 Inherited
Calling this method results in a call to the components validateDisplayList() method before the display list is rendered.
UIComponent
 Inherited
Calling this method results in a call to the components validateProperties() method before the display list is rendered.
UIComponent
 Inherited
measure(availableWidth:Number, availableHeight:Number):LayoutMeasurement
This method calls doMeasure() in order to calculate the preferred size of the control.
UIComponent
  
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
 Inherited
setActualSize(w:Number, h:Number):void
Sets the width and height of the object without setting the explicitWidth and explicitHeight.
UIComponent
 Inherited
setBackgroundSkin(_skin:Object):void
Sets the background skin for the ExpandableControl.
ExpandableControl
 Inherited
setButtonSkin(_skin:Object):void
Sets the button skin for the ExpandableControl.
ExpandableControl
 Inherited
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
 Inherited
setPosition(x:Number, y:Number):void
Sets the x and y position of the component.
UIComponent
 Inherited
setShadowSkin(_skin:Object):void
Sets the shadow skin for the ExpandableControl.
ExpandableControl
 Inherited
updateDefaultLocale(updateChildren:Boolean = true):void
Updates the locale property to be the same as the locale of the device.
UIComponent
 Inherited
Lets a component that contains text know that it should update its font formats as the font settings have changed.
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
 Inherited
Validates the display list of the component by calling the updateDisplayList().
UIComponent
 Inherited
Validates the component immediately by calling validateProperties(), validateSizes(), and validateDisplayList() if necessary.
UIComponent
 Inherited
Validates the properties of the component by calling the commitProperties() method.
UIComponent

Protected Methods

 MethodDefined By
 Inherited
allowShowContextMenu(target:IEventDispatcher):Boolean
When the user presses on the component this method is called with the object that dispatched the event.
UIComponent
 Inherited
Process properties of the component.
UIComponent
 Inherited
Process the state of the component.
UIComponent
 Inherited
Style the component after the style has changed.
UIComponent
 Inherited
doMeasure(availableWidth:Number, availableHeight:Number):LayoutMeasurement
Performs a measurement on the control, and returns a LayoutMeasurement instance containing the available width and height within the layout.
UIComponent
 Inherited
excemptFromCSSStyling(target:*, property:String = null):void
Exempts a property on an object from being styled by CSS.
UIComponent
 Inherited
flushCache():void
Invoked as part of parentLayoutChanged.
UIComponent
 Inherited
Gets a reference to the Container that contains this ExpandableControl, if one exists.
ExpandableControl
 Inherited
getStyleApplier():Function
A style applier is a method that gets called every time a property from the stylesheet should be applied to the component.
UIComponent
 Inherited
onAdded():void
Called when the instance is added to the stage.
UIComponent
 Inherited
Is called when a user is no longer long pressing on the component.
UIComponent
 Inherited
Is called when a user long presses on the component.
UIComponent
  
onRemoved():void
[override]
DropDown
 Inherited
Invalidates the parent's size and display list if includeInLayout property is set to true.
UIComponent
 Inherited
Calling this function will refresh the ContextMenu with whatever actions were set by contextActions.
UIComponent
 Inherited
Shows the context menu if there are contextActions associated with the control.
UIComponent
 Inherited
styleState():void
Style the component after state has changed.
UIComponent
 Inherited
updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
Sets the size and position of the children of the component.
UIComponent

Events

 Event Summary Defined By
 InheritedDispatched when an action in the Context Menu is selected.UIComponent
 InheritedDispatched when the ExpandableControl has finished closing.ExpandableControl
 InheritedDispatched when the ExpandableControl starts closing.ExpandableControl
 InheritedDispatched when the Context Menu has closed to the DISMISSED state.UIComponent
 InheritedDispatched when the ContextMenu is closing to the DISMISSED state.UIComponent
 InheritedDispatched when the Context Menu has opened to the PEEK or EXPANDED state.UIComponent
 InheritedDispatched when the ContextMenu is opening from the DISMISSED state.UIComponent
 InheritedDispatched when the CrossCut multiselect has been canceled.UIComponent
 InheritedDispatched when the ExpandableControl has finished opening.ExpandableControl
 InheritedDispatched when the ExpandableControl starts opening.ExpandableControl
  Dispatched when an item in the drop down list is selected.DropDown

Property Detail

cssID


cssID:String  [read-only]
[override]

Returns the CSS ID of the component. The CSS ID is used for identifying the type of component in CSS.

The default value is DropDown.


Implementation

protected function get cssID():String

dataProvider


dataProvider:IDataProvider

Gets or sets the DataProvider for the DropDown list.


Implementation

public function get dataProvider():IDataProvider
public function set dataProvider(value:IDataProvider):void

See also

DataProvider

isAlphabetical


isAlphabetical:Boolean
Deprecated: isAlphabetical has been deprecated. Optimizations surrounding alphabetical data for keyboard search have been internalized and as such this flag is no longer needed.

Gets or sets whether the contents of the DataProvider are in alphabetical order.

This property has been deprecated and no longer has any effect. Optimizations surrounding alphabetical data for keyboard search have been internalized and as such this flag is no longer needed.


Implementation

public function get isAlphabetical():Boolean
public function set isAlphabetical(value:Boolean):void

measureContents


measureContents:Boolean

Gets or sets a flag that is used to determine whether the control is sized based on its content when it is in a layout.

Note: If there is a large amount of data in the drop down list, setting measureContents to true may have a negative impact on its performance.


Implementation

public function get measureContents():Boolean
public function set measureContents(value:Boolean):void

rowCount


rowCount:int

Gets or sets the number of visible rows in the drop down list.


Implementation

public function get rowCount():int
public function set rowCount(value:int):void

rowHeight


rowHeight:int

Gets or sets the row height for the drop down list.

The row height represents ths height of each item in the list (in pixels).


Implementation

public function get rowHeight():int
public function set rowHeight(value:int):void

selectedIndex


selectedIndex:int

Gets or sets the index of the currently selected item in the drop down.


Implementation

public function get selectedIndex():int
public function set selectedIndex(value:int):void

selectedItem


selectedItem:Object

Gets 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);
}
         


Implementation

public function get selectedItem():Object
public function set selectedItem(value:Object):void

Constructor Detail

DropDown()


public function DropDown()

Creates a new DropDown instance.

Method Detail

addItem()


public function addItem(item:Object):void

Adds an item to the list.

Parameters

item:Object — The item to add.


Throws

RangeError — thrown if the specified index is less than 0 or greater than or equal to the length of the DataProvider.

addItemAt()


public function addItemAt(item:Object, index:int):void

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


Throws

RangeError — thrown if the specified index is less than 0 or greater than or equal to the length of the DataProvider.

addItemsAt()


public function addItemsAt(items:Array, index:int):void

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


Throws

RangeError — Thrown if the specified index is less than 0, or greater than or equal to the length of the data provider.

See also

addItem()
addItemAt()

getItemAt()


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.

Returns

Object — The item at the specified index.

Throws

RangeError — thrown if the specified index is less than 0 or greater than or equal to the length of the DataProvider.

onRemoved()


override protected function onRemoved():void

removeAll()


public function removeAll():void

Removes all the items from the list.

removeItem()


public function removeItem(item:Object):void

Removes the item from the list.

Parameters

item:Object — The item to remove.


Throws

ArgumentError — thrown if the item could not be found in the current DataProvider.

removeItemAt()


public function removeItemAt(index:int):void

Removes an item from list at the specified index.

Parameters

index:int — The index of the object to remove.


Throws

RangeError — thrown if the specified index is less than 0 or greater than or equal to the length of the DataProvider.

replaceItem()


public function replaceItem(item:Object, oldObject:Object):void

Replaces 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()


public function replaceItemAt(item:Object, index:int):void

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


Throws

RangeError — thrown if the specified index is less than 0 or greater than or equal to the length of the DataProvider.

setListSkin()


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()


public function updateItem(value:Object, oldObject:Object):void

Updates the item in the list.

Parameters

value:Object — The item to update.
oldObject:Object — old item, or the item to update.

updateItemAt()


public function updateItemAt(item:Object, index:int):void

Updates the item in the list at the specified index.

Parameters

item:Object — The updated item.
index:int — The index of the item to update.


Throws

RangeError — thrown if the specified index is less than 0 or greater than or equal to the length of the DataProvider.

updateItemsAt()


public function updateItemsAt(items:Array, index:int):void

Updates 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


Throws

RangeError — Thrown if the specified index is less than 0, or greater than or equal to the length of the DataProvider.

See also

updateItem()
updateItemAt()

Event Detail

select


Event Object Type: flash.events.Event
Event.type property = flash.events.Event.SELECT

Dispatched when an item in the drop down list is selected.

Examples

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="1280", width="768", frameRate="60", 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); 
            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);
        }
    }
}
     




comments powered by Disqus