Thanks everyone, I tried customizing it and have several problems:
-
The data is not coming out as I expect. I am putting in numbers from 1 to 59 and am seeing only 1 - 10 and with the numbers spelled out i.e “one”,“two”
-
The picker is not coming out as expected, I center the data and it comes out left handed justified.
-
Lastly, I keep getting a run error, please see below the code:
local age = function()
-- change the app's toolbar label
appToolbar.label = "enter age"
myPanel = display.newGroup()
local dateText, isPickerShowing, myPicker
-- create touchable text
local dateText = display.newText( "Touch here to enter age", 0, 0, "HelveticaNeue-Bold", 22 )
dateText:setTextColor( 0, 0, 0, 255 )
dateText:setReferencePoint( display.CenterReferencePoint )
dateText.x = display.contentWidth \* 0.5
dateText.y = 175
myPanel:insert( dateText )
-- touch listener for label (display.newText)
function dateText:touch( event )
if event.phase == "began" and not isPickerShowing then
isPickerShowing = true
local doneButton
local onDone = function( event )
-- get values from picker wheel
local age = myPicker.col.value
print("age is", age);
-- print("am I getting here");
if myPicker.col.listItems then
print( myPicker.col.listItems[1].titleText.text )
end
-- Update label text
dateText.text = age .. "is "
-- remove the button
display.remove( doneButton )
doneButton = nil
-- remove the picker wheel
display.remove( myPicker )
myPicker = nil
-- make date text touchable again
isPickerShowing = false
end
-- print("am I getting here1");
doneButton = newButton{ label="Done", size=12, onRelease=onDone }
doneButton:setReferencePoint( display.CenterRightReferencePoint )
doneButton.x = display.contentWidth - 5
doneButton.y = listBoxStart - 22
local col = {}
-- create first column & data
for i=1,59 do
col[i] = i
end
col.alignment = "center"
col.width = 50
col.startIndex = 10
-- print("am I getting to mypicker");
local myPicker = widget.newPickerWheel{
id="",
font="Helvetica-Bold",
columns=col
}
myPicker.y = display.contentHeight - myPicker.height
end
end
-- add touch listener to label text
dateText:addEventListener( "touch", dateText )
--
--
-- create back button
local myButton3 = newButton{ label="Go Back", x=0, y=display.contentHeight - 75, default="customButton.png", over="customButton\_over.png", onRelease=onButtonRelease }
myButton3:setReferencePoint( display.CenterReferencePoint )
myButton3.x = display.contentWidth \* 0.5
myPanel:insert( myButton3.view )
--
--
-- position this panel to the right of current view
myPanel.x = display.contentWidth
-- slide the api list to the left
apiList.view:slideLeft{ alpha=0 }
-- slide the content of this new "panel" to the left
myPanel:slideLeft{ slideAlpha=0, distance=display.contentWidth }
end -- end of "age" function
Here is the error
[code]
Copyright © 2009-2011 A n s c a , I n c .
Version: 2.0.0
Build: 2011.591
The file sandbox for this project is located at the following folder:
(/Users/alexdiaz/Library/Application Support/Corona Simulator/WidgetDemo-E572DCC64EED14454989F54E89BA81C0)
am I getting here1
am I getting to mypicker
Runtime error
…CoronaSDK/SampleCode/Interface/WidgetDemo/iphone.lua:561: attempt to index upvalue ‘myPicker’ (a nil value)
stack traceback:
[C]: ?
…CoronaSDK/SampleCode/Interface/WidgetDemo/iphone.lua:561: in function ‘_onRelease’
?: in function <?:887>
?: in function <?:215>
Runtime error
…CoronaSDK/SampleCode/Interface/WidgetDemo/iphone.lua:561: attempt to index upvalue ‘myPicker’ (a nil value)
stack traceback:
[C]: ?
…CoronaSDK/SampleCode/Interface/WidgetDemo/iphone.lua:561: in function ‘_onRelease’
?: in function <?:887>
?: in function <?:215>
Sorry, I did not copy the complete program just the portion for the wheelpicker, therefore the line numbers do not match. Line 561 where I get the error is line 29 here in this post.
[import]uid: 95689 topic_id: 18788 reply_id: 72546[/import]