How Do You Make The Picker Wheel Return The Right Information?

Hello,
I wanted to ask how do you make the picker wheel return the right information. Whenever I use the pickerWheel:getValues() command to return the information it always returns the information of the thing whatever was chosen before it. Thank you.

the code should be something like:

local theValues = pickerWheel:getValues()

print (#theValues,theValues[1].value)

When I do getValues() in the picker wheel listener function, it returns the old value of the picker wheel and not the changed new value.
I am trying to detect a change and then validate the new value. If the new value has a error then I want to enforce the correct selection using the setValue function.

to make sure that the listener is working properly add a button to print the current values of the pickerwheel instead of relying on the listener, if the values print ok, then the problem is in your listener in an event perhaps like “ended” or something like that … if the values are wrong then this should be a bug but mostly unlikely, because i’m always using the pickerwhell with no problems, but i always get the values from a button click not based on the PWheel listener

1 Like

Think I solved this riddle. Function pickerWheel:getValues() returns the values of the updated pickerwheel EXCEPT if this function is executed in the event listener function triggered by the pickerwheel’s onValueSelected parameter. In the latter case, pickerWheel:getValues() returns the values of the pickerwheel before it was changed by the user.

However, the listener funciton’s two event values identify the pickerwheel’s column index (event.column) that was changed and the index of the value that was picked (event.row). So you can get the updated value in the event listener function with the following code, provided that you have created the table for the pickerwheel’s columns parameter (here: columnData) before/’above’ the listener function:

columnData[event.column].labels[event.row]

I wonder whether this was meant to be so. It allows getting both the old and new value of the wheel that was changed by the user. If so, the documentation on object:getValues() should be adapted, because the sentence “Returns a table with the currently selected value/index of each column in the PickerWheelWidget.” is not entirely correct.