Trigger events when using Wheel Picker

Hello, I am a newby at Corona SDK.

I am creating an application which calculates numbers and I want to use the weel picker for the amount.

Is there any way to trigger an event when scrolling the wheel picker? (I have two values in the wheel picker)

Example:

-- Text field to display the amount choosen: local currentPicker = display.newText( "Bill Amount: 20.50", 0, 450, native.systemFont, 50 )     currentPicker.anchorX = 0     currentPicker.anchorY = 0     currentPicker.x = -50     currentPicker:setFillColor( 0 )

-- the wheel picker created: local pickerWheel = widget.newPickerWheel {     top = 200,     left = 50,     columns = columnData, }

-- the function which calles the values from the wheel picker: local function showValues( event )         local values = pickerWheel:getValues()         currentPicker.text = "Bill Amount: " .. values[1].value .. "." .. values[2].value         return true     end

The question is, can I put something in the wheel picker to return the value as soon as I pick them?

local pickerWheel = widget.newPickerWheel {     top = 200,     left = 50,     columns = columnData,     listener = showValues,     onRealease = showValues,     onClose = showValues,    }

Is there any command to call the values when they are picked or do I need a timer excecution for this?

– Get the table of current values for all columns
– This can be performed on a button tap, timer execution, or other event
local values = pickerWheel:getValues()

What other events can trigger the values to be displayed?

Thank you.

Huni.

Hi @huni,

You can use the :getValues() function to gather the current wheel values, but there is not a built-in way to “constantly track” which values are being selected as the user manipulates the wheel. However, while I haven’t actually tried it, you may be able to set up a separate touch listener on the wheel object and constantly return the values.

That being said, I actually don’t suggest that you use the pickerWheel for a column with 2 values. The picker is generally designed for larger amounts of data, and you may get some strange behavioral results with just 2 column values. Of course, you’re welcome to test this out, but I can’t vouch that it’ll work ideally.

Best regards,

Brent

Hi @huni,

You can use the :getValues() function to gather the current wheel values, but there is not a built-in way to “constantly track” which values are being selected as the user manipulates the wheel. However, while I haven’t actually tried it, you may be able to set up a separate touch listener on the wheel object and constantly return the values.

That being said, I actually don’t suggest that you use the pickerWheel for a column with 2 values. The picker is generally designed for larger amounts of data, and you may get some strange behavioral results with just 2 column values. Of course, you’re welcome to test this out, but I can’t vouch that it’ll work ideally.

Best regards,

Brent

Hi Brent,

Is there any possibility to cheat with widget picker wheel.

I have tried this code for scrollToIndex:

pickerWheel.\_view.\_columns[1]:scrollToIndex( 3 ) -- 3 is row index where we want to scroll

This code scrolling column 1 to index 3 but value is not stored for that column.
still getting value which selected before scrollToIndex function call (can say initial value in this case).

Is there any way to cheat on scroll complete ?

May i use “framework-widgets-legacy-master” from github ?
that is Widget 2.0 open source library.

Or is there any custom PickerWheel library that gives both functionality 

  1. On scroll complete and 
  2. Scroll to index

Please help me.

Thank you.

Bhavin :slight_smile:

 

Hi Bhavin,

Of course you are welcome to use the open-source widget library to build in custom functionality.

Or, I suppose you can use your code, but you’ll just need to use other variables to store the index value that you are doing “scrollToIndex” for. The wheel won’t store those since you’re “cheating” it, but you should be able to store the value somewhere.

You could combine that with the “On scroll complete” by using the “getValues()” call and storing the proper value to the same variable.

Hope this helps,

Brent

Hi Brent,

Is there any possibility to cheat with widget picker wheel.

I have tried this code for scrollToIndex:

pickerWheel.\_view.\_columns[1]:scrollToIndex( 3 ) -- 3 is row index where we want to scroll

This code scrolling column 1 to index 3 but value is not stored for that column.
still getting value which selected before scrollToIndex function call (can say initial value in this case).

Is there any way to cheat on scroll complete ?

May i use “framework-widgets-legacy-master” from github ?
that is Widget 2.0 open source library.

Or is there any custom PickerWheel library that gives both functionality 

  1. On scroll complete and 
  2. Scroll to index

Please help me.

Thank you.

Bhavin :slight_smile:

 

Hi Bhavin,

Of course you are welcome to use the open-source widget library to build in custom functionality.

Or, I suppose you can use your code, but you’ll just need to use other variables to store the index value that you are doing “scrollToIndex” for. The wheel won’t store those since you’re “cheating” it, but you should be able to store the value somewhere.

You could combine that with the “On scroll complete” by using the “getValues()” call and storing the proper value to the same variable.

Hope this helps,

Brent