Hello everyone 
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!