Class “Picker”

Object > NativeObject > Widget > Picker

A widget with a drop-down list of items to choose from.

Picker on Android
Android
Picker on iOS
iOS
Constructor public
Singleton No
Namespace tabris
Direct subclasses None
JSX support Element: <Picker/>
Parent element: <Composite/> and any widget extending Composite
Child elements: None
Text content: Not supported

Example

import {contentView, Picker} from 'tabris';

const items = ['Apple', 'Banana', 'Cherry'];

new Picker({
  itemCount: items.length,
  itemText: index => items[index]
}).onSelect(event => console.log(`Selected ${items[event.index]}`))
  .appendTo(contentView);

See also:

Constructor

new Picker(properties?)

Parameter Type Optional Description
properties Properties<Picker> & Partial<Pick<Picker, 'itemText'>> Yes Sets all key-value pairs in the properties object as widget properties.

Methods

set(properties)

Sets all key-value pairs in the properties object as widget properties.

Parameter Type Optional Description
properties Properties<this> & Partial<Pick<this, 'itemText'>> No  

Returns this

Properties

borderColor

The color of the border of the Picker. On iOS this is a rectangular border around the Picker, on Android it is a single line below the Picker.

Type ColorValue
Settable Yes

fillColor

iOS

The color of the background of the Picker - applies only to iOS.

Type ColorValue
Settable Yes

itemCount

The number of items to display.

Type number
Settable Yes

itemText

A function that returns the string to display for a given index.

Type (index: number) => string
Settable Yes

selectionIndex

The index of the currently selected item.

Type number
Settable Yes

textColor

The color of the text.

Type ColorValue
Settable Yes

Events

select

Fired when an item was selected by the user.

Parameter Type Description
index number Contains the index of the selected item.

Change Events

itemCountChanged

Fired when the itemCount property has changed.

Parameter Type Description
value number The new value of itemCount.

itemTextChanged

Fired when the itemText property has changed.

Parameter Type Description
value (index: number) => string The new value of itemText.

selectionIndexChanged

Fired when the selectionIndex property has changed.

Parameter Type Description
value number The new value of selectionIndex.

fillColorChanged

Fired when the fillColor property has changed.

Parameter Type Description
value ColorValue The new value of fillColor.

borderColorChanged

Fired when the borderColor property has changed.

Parameter Type Description
value ColorValue The new value of borderColor.

textColorChanged

Fired when the textColor property has changed.

Parameter Type Description
value ColorValue The new value of textColor.