qnx.fuse.ui.picker.Picker

Picker

Properties | Methods | Events | Examples


Packageqnx.fuse.ui.picker
Classpublic class Picker
InheritancePicker Inheritance ExpandableControl Inheritance UIComponent Inheritance flash.display.MovieClip
Implements IDataViewer

The Picker class is similar to a DropDown, but allows for multiple columns of choices. It is ideal for inputting information that consists of multiple points of grouped data, like dates or times.

The following image shows a Picker instance in the closed state:

A closed picker.

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

An open picker.

Class information:
BlackBerry 10 Version:   10.0.0
Found in:  qnxui.swc

View the examples

See also

DropDown
ExpandableControl



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 and sets the DataProvider for the Picker instance.
Picker
 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
 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.
Picker
 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 an integer that determines the number of rows the Picker will display.
Picker
  rowHeight : int
Gets or sets the row height property of the list items and the middle section of the picker (button bar).
Picker
  selectedIndices : Array
Gets or sets the selected index for each list in a Picker.
Picker
  selectedItems : Array
Gets or sets the group of selected items for each list in the Picker.
Picker
 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
  valueFunction : Function
If set, this function is called with the selected items of the Picker and returns a String to be used in the value label.
Picker

Protected Properties

 PropertyDefined By
 InheritedaccessibilityImplimentationClass : Class
UIComponent
  cssID : String
[override] [read-only] Returns the CSS ID of the component.
Picker
 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 Picker instance.
Picker
  
addItem(item:Object):void
Adds a column of data to the Picker, given an DataProvider instance.
Picker
  
addItemAt(item:Object, index:int):void
Adds a column of data to the Picker, given a DataProvider and an offset.
Picker
  
addItemsAt(items:Array, index:int):void
Adds columns of data to the Picker given an Array of DataProvider objects.
Picker
 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 data of the column instance at the specified index.
Picker
  
getListAt(index:int):List
Gets the List at a given index.
Picker
  
getLists():Array
Returns an array of List instances used to populate the columns in the picker.
Picker
  
getListSkin():Object
Gets the skin object that is used by the list.
Picker
  
getListSkinAt(index:int):Object
Gets the list skin, given the index of the List.
Picker
 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 columns of data from the list.
Picker
  
removeItem(item:Object):void
Removes a column of data from the Picker, given the DataProvider instance that is used by the column.
Picker
  
removeItemAt(index:int):void
Removes a column of data from the Picker at the specified index.
Picker
  
replaceItem(item:Object, oldObject:Object):void
Replaces a column of data given a new DataProvider instance and the existing DataProvider instance to replace.
Picker
  
replaceItemAt(item:Object, index:int):void
Replaces a column of data given the new DataProvider instance and the index of the column to replace.
Picker
 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
  
setHighlightBackgroundSkin(skin:Object):void
Sets the skin for the highlighted row background.
Picker
  
setHighlightForegroundSkin(skin:Object):void
Sets the skin for the highlighted row foreground.
Picker
 Inherited
setLayoutBounds(bounds:Rectangle):void
Sets the receiver's size and location to the rectangular area specified by the arguments.
UIComponent
  
setListDividerSkin(skin:Object):void
Sets the skin for the list divider.
Picker
  
setListSkin(skin:Object):void
Sets the skin for the list.
Picker
  
setListSkinAt(skin:Object, listAtIndex:int = 0):void
Sets the list skin for the List (or column) instance at the given index.
Picker
  
setListWidth(listAtIndex:int = 0, listWidth:int = 100):void
Sets the width of a list given an index and a width in pixels.
Picker
 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 a column of data given a new DataProvider instance and the existing DataProvider instance.
Picker
  
updateItemAt(item:Object, index:int):void
Updates a column of data given the new DataProvider instance and the index of the column to replace.
Picker
  
updateItemsAt(items:Array, index:int):void
Updates columns of data, given a new Array of DataProvider instances and the index at which to add the Array.
Picker
 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
 Inherited
onRemoved():void
Called when the instance is removed from the stage.
UIComponent
 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
  Dispatched when the DataProvider changes for the picker component.Picker
 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 the user selects an item from a column in the picker.Picker

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


Implementation

protected function get cssID():String

dataProvider


dataProvider:IDataProvider

Gets and sets the DataProvider for the Picker instance. This must be of type IDataProvider.

In the example below, the dataProvider property is set by passing in a DataProvider instance. Each item in the dataProvider property represents a column in the picker and should be of type IDataProvider.

var i:int = 0;
var hours:DataProvider = new DataProvider();
for( i = 0; i<=11; ++i)
{
    hours.addItem( { label:( i == 0 ) ? "12" : i });
}
var minutes:DataProvider = new DataProvider();
for( i = 0; i<=59; ++i)
{
    minutes.addItem( { label: (""+Math.floor(i/10))+(i%10)} );
}
var dp:DataProvider = new DataProvider();
dp.addItem( hours );
dp.addItem( minutes );
dp.addItem( new DataProvider( [{label:"AM"},{label:"PM"}] ) );
picker.dataProvider = dp;
         


Implementation

public function get dataProvider():IDataProvider
public function set dataProvider(value:IDataProvider):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 picker, 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 an integer that determines the number of rows the Picker will display.

The value for this property must always be an odd number. This will allow the middle row to be centered within the button, with the adjacent cells above and below the selection.


Implementation

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

Throws
ArgumentError — Thrown if the rowCount is set to an even number.

rowHeight


rowHeight:int

Gets or sets the row height property of the list items and the middle section of the picker (button bar).


Implementation

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

selectedIndices


selectedIndices:Array

Gets or sets the selected index for each list in a Picker.


Implementation

public function get selectedIndices():Array
public function set selectedIndices(value:Array):void

selectedItems


selectedItems:Array

Gets or sets the group of selected items for each list in the Picker.


Implementation

public function get selectedItems():Array
public function set selectedItems(value:Array):void

Throws
ArgumentError — Thrown if one of the specified item is not currently in the DataProvider of the list.

valueFunction


valueFunction:Function

If set, this function is called with the selected items of the Picker and returns a String to be used in the value label. The value label displays the currently selected items in the Picker. This is useful if you need to format the the selected values before displaying them, such as with dates or currencies. The method should return a String. It is invoked with one argument, an array of selected items. function callback(selectedItems:Array):String; In this example we separate items in a two column Picker by their mathematical relation to each other, either greater than, less than, or equal to.

var picker : Picker = new Picker();
var dp : DataProvider = new DataProvider();
for ( var i : int = 0; i < 2; i++ )
{
    var list : DataProvider = new DataProvider();
    for ( var k : int = 0; k < 10; k++ )
    {
        list.addItem( { label:k.toString(), value:k } );
    }
    dp.addItem( list );
}
picker.dataProvider = dp;
picker.valueFunction = function(selectedItems:Array) : String
{
    var item1 : Number = selectedItems[0]['value'];
    var item2 : Number = selectedItems[1]['value'];
    if (item1 > item2) return item1 + " > " + item2;
    else if (item1 < item2) return item1 + " < " + item2;
    else return item1 + " == " + item2;
};
addChild(picker);
         


Implementation

public function get valueFunction():Function
public function set valueFunction(value:Function):void

Constructor Detail

Picker()


public function Picker()

Creates a new Picker instance.

Method Detail

addItem()


public function addItem(item:Object):void

Adds a column of data to the Picker, given an DataProvider instance.

var arrMonth_fr:Array = new Array();
arrMonth_fr.push({label: "Janvier"});
arrMonth_fr.push({label: "Fevrier"});
arrMonth_fr.push({label: "Mars"});
arrMonth_fr.push({label: "Avril"});
arrMonth_fr.push({label: "Mai"});
arrMonth_fr.push({label: "Juin"});
arrMonth_fr.push({label: "Juillet"});
arrMonth_fr.push({label: "Aout"});
arrMonth_fr.push({label: "Septembre"});
arrMonth_fr.push({label: "Octobre"});
arrMonth_fr.push({label: "Novembre"});
arrMonth_fr.push({label: "Decembre"});
var month_frDP:DataProvider = new DataProvider(arrMonth_fr);
picker.addItem(month_frDP);
         

Parameters

item:Object — The data that represents the column in the picker. Must be of type IDataProvider.

addItemAt()


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

Adds a column of data to the Picker, given a DataProvider and an offset.

In the following example, the addItemsAt() method is called to set the DataProvider for the third column in the Picker.

var arrMonth_fr:Array = new Array();
arrMonth_fr.push({label: "1"});
arrMonth_fr.push({label: "2"});
arrMonth_fr.push({label: "3"});
arrMonth_fr.push({label: "4"});
arrMonth_fr.push({label: "5"});
arrMonth_fr.push({label: "6"});
arrMonth_fr.push({label: "7"});
arrMonth_fr.push({label: "8"});
arrMonth_fr.push({label: "9"});
arrMonth_fr.push({label: "10"});
arrMonth_fr.push({label: "11"});
arrMonth_fr.push({label: "12"});
var month_nums:DataProvider = new DataProvider(arrMonth_fr);
picker.addItemAt(month_nums, 2);
         

Parameters

item:Object — The DataProvider to add. Must be of type IDataProvider.
index:int — The offset value at which to add the column.


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 columns of data to the Picker given an Array of DataProvider objects.

Parameters

items:Array — The array of DataProvider instances to add. Each DataProvider must be of type IDataProvider.
index:int — The index, or offset, at which to add the array.


Throws

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

See also

addItem()
addItemAt()

getItemAt()


public function getItemAt(index:int):Object

Returns the data of the column instance at the specified index.

Parameters

index:int — The index of the column for which to return the DataProvider.

Returns

Object — The DataProvider instance (of type IDataProvider) 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.

getListAt()


public function getListAt(index:int):List

Gets the List at a given index.

The following routine shows the getListAt() method being used to update the selected picker item with timer information:

private function updatePicker():void
{
    // hours col
    picker.getListAt(0).selectedIndex = countDownDate.hoursUTC;
    // minutes col
    picker.getListAt(1).selectedIndex = countDownDate.minutesUTC;
    // secs col
    picker.getListAt(2).selectedIndex = countDownDate.secondsUTC;
}
         

Parameters

index:int — An integer representing the index of the List.

Returns

List — The List at the given index.

Throws

RangeError — Thrown if the supplied index is not within the number of lists.

getLists()


public function getLists():Array

Returns an array of List instances used to populate the columns in the picker.

Returns

Array — An Array of List objects.

getListSkin()


public function getListSkin():Object

Gets the skin object that is used by the list. This is the default skin for all cells in picker columns.

Returns

Object — The Skin object. This can be the Class or the qualified class name of the skin.

getListSkinAt()


public function getListSkinAt(index:int):Object

Gets the list skin, given the index of the List.

Parameters

index:int — The index of the List

Returns

Object — The Skin object. This can be the Class or the qualified class name of the skin.

removeAll()


public function removeAll():void

Removes all columns of data from the list.

removeItem()


public function removeItem(item:Object):void

Removes a column of data from the Picker, given the DataProvider instance that is used by the column.

The removeItem() method removes the DataProvider that is associated with the column. In the following listing, a DataProvider instance is passed into the removeItem() method to remove the associated column:

picker.removeItem(month_frDP);
         

The DataProvider instance month_frDP was previously added to the Picker.

Parameters

item:Object — The DataProvider instance that is associated with the List instance (or column) to be removed. Must be of type IDataProvider.


Throws

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

removeItemAt()


public function removeItemAt(index:int):void

Removes a column of data from the Picker at the specified index.

Parameters

index:int — The index of the List (or column), 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 a column of data given a new DataProvider instance and the existing DataProvider instance to replace.

The following listing creates a new DataProvider instance containing English month names. The new DataProvider instance is passed into the replaceItem() method along with the existing DataProvider instance (which contains French month names):

var arrMonth_en:Array = new Array();
arrMonth_en.push({label: "January"});
arrMonth_en.push({label: "February"});
arrMonth_en.push({label: "March"});
arrMonth_en.push({label: "April"});
arrMonth_en.push({label: "May"});
arrMonth_en.push({label: "June"});
arrMonth_en.push({label: "July"});
arrMonth_en.push({label: "August"});
arrMonth_en.push({label: "September"});
arrMonth_en.push({label: "October"});
arrMonth_en.push({label: "November"});
arrMonth_en.push({label: "December"});
                
var month_enDP:DataProvider = new DataProvider(arrMonth_en);            
            
picker.replaceItem( month_enDP, month_frDP);
        

Parameters

item:Object — The new DataProvider instance. Must be of type IDataProvider.
oldObject:Object — The DataProvider instance to replace. Must be of type IDataProvider.

replaceItemAt()


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

Replaces a column of data given the new DataProvider instance and the index of the column to replace.

Parameters

item:Object — The new DataProvider instance. Must be of type IDataProvider.
index:int — The index of the column to replace.


Throws

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

setHighlightBackgroundSkin()


public function setHighlightBackgroundSkin(skin:Object):void

Sets the skin for the highlighted row background.

You can pass in a qualified class name String, or the actual class.

Note: Do not pass in an instance of a skin class. Pass the class name instead.

Parameters

skin:Object — The Skin object to set.

setHighlightForegroundSkin()


public function setHighlightForegroundSkin(skin:Object):void

Sets the skin for the highlighted row foreground.

You can pass in a qualified class name String, or the actual class.

Note: Do not pass in an instance of a skin class. Pass the class name instead.

Parameters

skin:Object — The Skin object to set.

setListDividerSkin()


public function setListDividerSkin(skin:Object):void

Sets the skin for the list divider.

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 object to set.

setListSkin()


public function setListSkin(skin:Object):void

Sets the skin for the list.

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 object to set.

setListSkinAt()


public function setListSkinAt(skin:Object, listAtIndex:int = 0):void

Sets the list skin for the List (or column) instance at the given index.

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 to set for the list.
listAtIndex:int (default = 0) — The index of the List.


Throws

RangeError — Thrown if the supplied index is not within the range of the number of lists.
Error — Thrown if there are no lists.

setListWidth()


public function setListWidth(listAtIndex:int = 0, listWidth:int = 100):void

Sets the width of a list given an index and a width in pixels.

Setting the width through this accessor method, rather than getting the column and setting it directly, ensures that the lists are properly laid out.

Parameters

listAtIndex:int (default = 0) — The index of the List for which to set the width. Default value is 0 (first list).
listWidth:int (default = 100) — The width value which will be treated as a ratio with the width of the component. All sizes are added up ( for the columns ) and then calculated as a percentage of the overall width of the component. Default value is 100.

updateItem()


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

Updates a column of data given a new DataProvider instance and the existing DataProvider instance.

The following listing creates a new DataProvider instance containing English month names. The new DataProvider instance is passed into the updateItem() method along with the existing DataProvider instance (which contains French month names):

var arrMonth_en:Array = new Array();
arrMonth_en.push({label: "January"});
arrMonth_en.push({label: "February"});
arrMonth_en.push({label: "March"});
arrMonth_en.push({label: "April"});
arrMonth_en.push({label: "May"});
arrMonth_en.push({label: "June"});
arrMonth_en.push({label: "July"});
arrMonth_en.push({label: "August"});
arrMonth_en.push({label: "September"});
arrMonth_en.push({label: "October"});
arrMonth_en.push({label: "November"});
arrMonth_en.push({label: "December"});
var month_enDP:DataProvider = new DataProvider(arrMonth_en);            
picker.updateItem(month_enDP, month_frDP);
         

Parameters

value:Object — The new DataProvider instance. Must be of type IDataProvider.
oldObject:Object — The existing DataProvider instance to update. Must be of type IDataProvider.

updateItemAt()


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

Updates a column of data given the new DataProvider instance and the index of the column to replace.

Parameters

item:Object — The new DataProvider instance. Must be of type IDataProvider.
index:int — The index of the column.


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 columns of data, given a new Array of DataProvider instances and the index at which to add the Array.

Parameters

items:Array — The Array of DataProvider instances that are used by the columns. The DataProvider instances must be of type IDataProvider.
index:int — The offset at which to update the columns.


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

change


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

Dispatched when the DataProvider changes for the picker component.

select


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

Dispatched when the user selects an item from a column in the picker.

Examples

In the following example, a time Picker is created.
package
{
    import qnx.fuse.ui.picker.Picker;
    import qnx.ui.data.DataProvider;
    import flash.display.Sprite;
    
    [SWF(height="1280", width="768", frameRate="60", backgroundColor="#FFFFFF")]
    public class PickerTest extends Sprite
    {
        private var picker : Picker;
        
        public function PickerView()
        {
            super();
            initializeUI();
        }
        
        private function initializeUI() : void
        {
            picker = new Picker();
            picker.prompt = "Choose a Time";
            picker.dataProvider = createDataProvider();
            picker.valueFunction = formatValue;
            picker.addEventListener(Event.SELECT, onPickerSelection );
            addChild( picker );
        }
        
        private function onPickerSelection(event : Event) : void
        {
            trace("selected indices: " + event.target.selectedIndices);
        }
        
        private function formatValue(selectedItems : Array) : String
        {
            return selectedItems[0]['label'] + ':' + selectedItems[1]['label'] + ' ' + selectedItems[2]['label'];
        }
        
        private function createDataProvider() : DataProvider
        {
            var hours : Array = [];
            for( var i : int = 1; i <= 12; i++ )
            {
                hours.push( { label:i } );
            }
            
            var minutes : Array = [];
            for( var j : int = 0; j < 60; j++ )
            {
                if(j < 10)
                {
                    minutes.push( {label: "0" + j.toString() } );
                }
                else
                {
                    minutes.push( { label:j } );
                }
            }
            
            var AMPM : Array = [];
            AMPM.push( { label:"AM" } );
            AMPM.push( { label:"PM" } );
            
            return new DataProvider( [ new DataProvider( hours ), new DataProvider( minutes ), new DataProvider( AMPM ) ] );
        }
    }
}
     




comments powered by Disqus