Type Function Library widget.* Return value none Revision Release 2024.3703 Keywords widget, picker, PickerWheelWidget, selectValue See also widget.newPickerWheel() PickerWheelWidget
Selects a specific row within a specific column of the PickerWheelWidget. Optionally allows you to snap directly/instantly to the row instead of via default scrolling motion.
onValueSelected
listener function in the widget’s constructor, that function will be called when this command executes.object:selectValue( targetColumn, targetIndex [, snapToIndex] )
Number. Integer indicating the column to manipulate, from 1
to the total number of columns in the PickerWheelWidget
Number. Integer indicating the row index to select within the specified column (targetColumn
). This must be a valid row index from 1
to the total number of rows in the column.
Boolean. If true
, the specified column+row selection will be instantly selected (no scrolling motion). Default is false
.
local widget = require( "widget" ) -- Set up the picker wheel columns local columnData = { { align = "left", width = 124, labelPadding = 20, startIndex = 2, labels = { "Hoodie", "Short Sleeve", "Long Sleeve", "Sweatshirt" } }, { align = "left", width = 96, labelPadding = 10, startIndex = 1, labels = { "Dark Grey", "White", "Black", "Orange" } }, { align = "left", width = 60, labelPadding = 10, startIndex = 3, labels = { "S", "M", "L", "XL", "XXL" } } } -- Create the widget local pickerWheel = widget.newPickerWheel( { x = display.contentCenterX, top = display.contentHeight - 160, columns = columnData, style = "resizable", width = 280, rowHeight = 32, fontSize = 14 }) -- Select the third row in the first column pickerWheel:selectValue( 1, 3 ) -- After 4000 milliseconds (4 seconds), select the fourth row in the second column timer.performWithDelay( 4000, function() pickerWheel:selectValue( 2, 4 ); end )