Problem with PickerWheel Widget - selecting the value

Hello everyone :slight_smile:

I am still at my first application with corona sdk and i am performing a digital timer;

I’m using a PickerWheel widget for selecting the time, and the logic should be: 

i press the button to select the time, pickerwheel become visible, i select the time, the label of the button become the selected time, the pickerwheel become not visible:

These are the lines of code:

local widget = require( "widget" ) --require ("widgetLibrary.widgetext") --require ("widgets.storyboardext") display.setDefault( "anchorX", 0.5 ) display.setDefault( "anchorY", 0 ) local buttonTime local timeisblank = true local columnData = { -- Time { align = "center", width = 140, startIndex = 3, labels = { 10, 20, 25, 30, 35, 40, 45, 50, 55, 60} } } -- Image sheet options and declaration local options = { frames = { { x=0, y=0, width=320, height=222 }, { x=320, y=0, width=320, height=222 }, { x=640, y=0, width=8, height=222 } }, sheetContentWidth = 648, sheetContentHeight = 222 } local pickerWheelSheet = graphics.newImageSheet( "pickerSheet.png", options ) -- Create the widget local pickerWheel2 = widget.newPickerWheel { top = display.contentHeight - 1150, columns = columnData, sheet = pickerWheelSheet, overlayFrame = 1, overlayFrameWidth = 320, overlayFrameHeight = 222, backgroundFrame = 2, backgroundFrameWidth = 320, backgroundFrameHeight = 222, separatorFrame = 3, separatorFrameWidth = 8, separatorFrameHeight = 222, columnColor = { 0, 0, 0, 0 }, fontColor = { 0.4, 0.4, 0.4, 0.5 }, fontColorSelected = { 0.2, 0.6, 0.4 } } pickerWheel2.isVisible = false ----------------------------------- local function handleButtonEvent( event ) pickerWheel2.isVisible = true if (pickerWheel2.isVisible) then local values = pickerWheel2:getValues() print(values[1].value) \_G.Reg = values[1].value timeisblank = false buttonTime:setLabel( \_G.Reg ) pickerWheel2.isVisible = false end end ----------------------------------- local labelTime = display.newText( "Time ", 40, 120, native.systemFont, 18 ) --selectedTime= native.newTextField( 150, 145, 50, 40 ) ------------------------ -------------- buttonTime = widget.newButton { top= 190, left=10, width = 100, height = 39, defaultFile = "XDXD.png", overFile = "XDXDATTIVO.png", --label = "button", onPress = handleButtonEvent }

I would really have an advice, 'cause if i use that " if " in the function, I can not even see the PickerWhell for selecting the time (and i don’t know if is a simulator dynamics that could be fixed trying the code on a smartphone); else, if i don’t use that " if " , the code was this :

local function handleButtonEvent( event ) pickerWheel2.isVisible = true local values = pickerWheel2:getValues() \_G.Reg = values[1].value buttonTime:setLabel( \_G.Reg ) if (buttonTime.label==\_G.Reg) then pickerWheel2.isVisible = false end end

This time with a different " if " where i can see the pickerwhell but where i can have to press two time on the button before the label change 

Any help would be really great!

Thanks in advance!

Hello everyone!

Trying to resolve this problem (still workin on it ) i thought that maybe i have to use touch events for show/hide the pickerwheel pressing the botton and getting the value with a tap on the value.

This could be a good way for resolving my problem? Can someone help me with this or help me anyway if touch events are not necessary?

EDIT: I have now realized that i should use a control variable relative to the button state (boolean) for showing and hiding the pickerwheel. Does touch events are still necessary to get istant the value tapping on them?

Thank you so much in advance, i hope i have explained well my problem.

Hello everyone!

Trying to resolve this problem (still workin on it ) i thought that maybe i have to use touch events for show/hide the pickerwheel pressing the botton and getting the value with a tap on the value.

This could be a good way for resolving my problem? Can someone help me with this or help me anyway if touch events are not necessary?

EDIT: I have now realized that i should use a control variable relative to the button state (boolean) for showing and hiding the pickerwheel. Does touch events are still necessary to get istant the value tapping on them?

Thank you so much in advance, i hope i have explained well my problem.