Syntax

This function takes a single argument, options, which is a table that accepts the following parameters:

id (optional)

String. An optional identification to assign to the picker wheel. Default is widget_pickerWheel.

x, y (optional)

Numbers. Coordinates for the widget's x and y center point. These values will be overridden by left and top if those values are defined.

left, top (optional)

Numbers. The left and top position where the widget will be created. If specified, these values override the x and y parameters.

columns (required)

Table. A table which contains a sub-table for each individual column within the picker wheel. See Configuring Columns below.

style (optional)

String. Indicates the picker wheel construction style. If set to "resizable", construction will adhere to the design outlined in Resizable Construction below. If omitted, construction will adhere to a fixed size of 320×222.

onValueSelected (optional)

Listener. Optional listener function which is triggered when the user selects an item in the picker wheel, or upon calling object:selectValue().

Methods

Configuring Columns

Columns within the picker wheel are defined by an ordered series of sub-tables within the required columns table. These columns will be added to the picker wheel from left to right, in the order you define them.

Each sub-table within the columns table accepts the following parameters:

labels (required)

Table. A table of ordered values that represent the label for each row in the column. For example:

width (optional)

Number. By default, columns are split evenly between the picker wheel's viewable area, but a column's width can be defined via the width property — this allows you to resize each column width to better fit its defined labels.

align (optional)

String. Specifies the alignment of the text labels within the column. Acceptable values are "left", "center", or "right". Default is "center".

labelPadding (optional)

Number. An optional number of pixels to pad/offset the picker column labels. If align is set to "left", padding will occur from the left edge of the column; if align is set to "right", padding will occur from the right edge. Default is 6.

startIndex (required)

Number. The column's initially-selected row. This cannot be set higher than the column's total range of values.

fontSize (optional)

fontColor (optional)

Table. Table specifying an RGB+A color for the font color of the "unselected" picker wheel labels.

fontColor = { 0.2, 0.2, 0.2 }

fontColorSelected (optional)

Table. Table specifying an RGB+A color for the font color of the "selected" picker wheel labels.

fontColorSelected = { 1, 0, 0 }

columnColor (optional)

Table. Table specifying an RGB+A color setting for the background color of the picker wheel columns.

columnColor = { 0.8, 0.8, 0.8 }

Resizable Construction

Resizable picker wheels can be constructed at a size which fits your user interface — simply set style to "resizable" in the widget constructor parameters and include these additional required parameters:

Important

The border/overlay frame construction is optional, but if you want to include a border, you must specify all of the frame indices necessary to construct it (eight in total).

Resizable picker wheels are not compatible with legacy widget themes. If you're implementing a resizable picker wheel, you should explicitly set a non-legacy theme via widget.setTheme(), such as "widget_theme_android_holo_dark", "widget_theme_android_holo_light", or "widget_theme_ios7".

width (required)

rowHeight (required)

Number. An integer which sets the height of each row in the picker wheel's columns. Because picker wheels are strictly designed to display 5 rows — a center selection row for the selected options along with two additional rows above and below — the overall height of the picker wheel will be 5 times this value. For instance, if you set rowHeight to 40, the resulting picker wheel will be 200 pixels in overall height.

In addition, you can visually customize resizable picker wheels using frames from an image sheet. As indicated in the following image, this includes:

An optional border overlay of eight frames constructed from four corners (1), upper/lower horizontal spans (2), and left/right vertical spans (3). The span frames will be stretched to fill the space between the corner frames.

An optional top fade span (4) and bottom fade span (5). These will be stretched to the full width of the picker wheel.

Optional upper and lower frames (6 and 7) which span across the vertical center to highlight the "selection" row. These will be stretched to the full width of the picker wheel.

Optional separator/divider (8) that will be automatically placed between the columns (underneath the border overlay and above the other elements).

sheet (required)

topLeftFrame (optional)

Number. The index number for the top-left corner frame of the picker wheel border/overlay.

topMiddleFrame (optional)

Number. The index number for the top-middle side of the picker wheel border/overlay. This frame will be stretched to span the distance between the top-left and top-right corner frames.

topRightFrame (optional)

Number. The index number for the top-right corner frame of the picker wheel border/overlay.

middleLeftFrame (optional)

Number. The index number for the middle-left side of the picker wheel border/overlay. This frame will be stretched to span the distance between the top-left and bottom-left corner frames.

middleRightFrame (optional)

Number. The index number for the middle-right side of the picker wheel border/overlay. This frame will be stretched to span the distance between the top-right and bottom-right corner frames.

bottomLeftFrame (optional)

Number. The index number for the bottom-left corner frame of the picker wheel border/overlay.

bottomMiddleFrame (optional)

Number. The index number for the bottom-middle side of the picker wheel border/overlay. This frame will be stretched to span the distance between the bottom-left and bottom-right corner frames.

bottomRightFrame (optional)

Number. The index number for the bottom-right corner frame of the picker wheel border/overlay.

topFadeFrame (optional)

Number. The index number for the top fade frame. This frame resides underneath the border/overlay and above the picker wheel columns. Its top edge aligns with the top of the picker wheel and it is stretched to span the defined width. This can be used to simulate a visual fade-out effect for column labels as they move outside the top edge of the wheel.

bottomFadeFrame (optional)

Number. The index number for the bottom fade frame. This frame resides underneath the border/overlay and above the picker wheel columns. Its bottom edge aligns with the bottom of the picker wheel and it is stretched to span the defined width. This can be used to simulate a visual fade-out effect for column labels as they move outside the bottom edge of the wheel.

middleSpanTopFrame (optional)

Number. The index number for the upper middle span frame. This frame resides underneath the border/overlay and above the picker wheel columns. Its top edge aligns with the top edge of the picker wheel's center selection row and it is stretched to span the defined width. If desired, the vertical alignment can be adjusted via middleSpanOffset as noted below.

middleSpanBottomFrame (optional)

Number. The index number for the lower middle span frame. This frame resides underneath the border/overlay and above the picker wheel columns. Its bottom edge aligns with the bottom edge of the picker wheel's center selection row and it is stretched to span the defined width. If desired, the vertical alignment can be adjusted via middleSpanOffset as noted below.

backgroundFrame (optional)

Number. The index number for the background frame that resides behind the picker wheel. This frame will be stretched to span the picker wheel's defined width and constructed height.

separatorFrame (optional)

Number. The index number for the separator/divider frame. These separators will be automatically placed between the columns and they will be stretched to span the constructed height.

middleSpanOffset (optional)

Number. An offset value for both the upper and lower middle span frames. If positive, this value will offset middleSpanTopFrame upwards and middleSpanBottomFrame downwards from their default positions. This can be used to adjust the "spread" of the span frames in relation to the center selection row. Negative values are allowed.

borderPadding (optional)

Number. The number of pixels to pad the border/overlay on all sides. This can be used to expand the border frame beyond the picker wheel's defined width and constructed height.

Fixed-Size Customization

Fixed-size picker wheels can be visually customized using frames from an image sheet. As exhibited in the following image, this consists of three frames: an overlay (left), a background frame which resides behind the overlay (center), and an optional separator/divider (right) that will be automatically placed between the columns (underneath the overlay and above the background).