Hello all,
I’m still having trouble on doing a basic implementation of the date pickerWheel.
The “roll over effect” of the date, month, or year sometimes works and sometimes doesn’t work for me properly.
That is, when I place the pickerWheel in between Jan and Feb. it sometimes rolls over to the prev. month (Jan) or the next month (Feb) or
it just stays in the middle.
The problem is when it stays in the middle.
[sharedmedia=core:attachments:1036]
After I click the button (to get the values from the pickerWheel) which calls the function
values = pickerWheel:getValues() -- Update the status box text statusText.text = "Column 1: " .. values[1].value .. "\nColumn 2: " .. values[2].value .. "\nColumn 3: " .. values[3].value
And when I go to see the value, I get
Runtime error
: attempt to index field ‘?’ (a nil value)
stack traceback:
[C]: ?
…: in function '_onRelease’
?: in function '?'
?: in
Here is the complete code
local widget = require( "widget" ) local storyboard = require( "storyboard" ) local scene = storyboard.newScene() local values local pickerWheel local columnData local days = {} local years = {} -- Our scene function scene:createScene( event ) local group = self.view -- Display a background local background = display.newImage( "some\_screen\_background.png", true ) group:insert( background ) -- Status text box local statusBox = display.newRect( 50, 60, 210, 80 ) statusBox:setFillColor( 0, 0, 0 ) statusBox.alpha = 0.4 group:insert( statusBox ) -- Status text local statusText = display.newText( "Press the values button to show the current values.", 80, 350, 200, 0, native.systemFont, 18 ) statusText.x = statusBox.x statusText.y = statusBox.y - ( statusBox.contentHeight \* 0.5 ) + ( statusText.contentHeight \* 0.5 ) group:insert( statusText ) --------------------------------------------------------------------------------------------- -- widget.newPickerWheel() --------------------------------------------------------------------------------------------- for i = 1, 31 do days[i] = i end for i = 1, 44 do years[i] = 1969 + i end -- Set up the Picker Wheel's columns columnData = { { align = "right", width = 150, startIndex = 5, labels = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }, }, { align = "left", width = 60, startIndex = 18, labels = days, }, { align = "center", width = 80, startIndex = 10, labels = years, }, } -- Create a new Picker Wheel pickerWheel = widget.newPickerWheel { top = 210, font = native.systemFontBold, columns = columnData, } group:insert( pickerWheel ) local function showValues( event ) -- Retrieve the current values from the picker values = pickerWheel:getValues() -- Update the status box text statusText.text = "Column 1: " .. values[1].value .. "\nColumn 2: " .. values[2].value .. "\nColumn 3: " .. values[3].value -- Update the status box text position statusText.x = statusBox.x statusText.y = statusBox.y - ( statusBox.contentHeight \* 0.5 ) + ( statusText.contentHeight \* 0.5 ) pickerWheel.isVisible = false return true end local getValuesButton = widget.newButton { left = 10, top = 150, width = 298, height = 56, id = "getValues", label = "Values", onRelease = showValues, } group:insert( getValuesButton ) local function showWheel( event ) -- show the wheel again pickerWheel.isVisible = true return true end local getWheelButton = widget.newButton { left = 310, top = 150, width = 298, height = 56, id = "getValues", label = "Show Wheels", onRelease = showWheel, } group:insert( getWheelButton ) end scene:addEventListener( "createScene" ) return scene
Could it be the config.lua file?
application = { content = { width = 640, height = 960, scale = "letterBox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, }