I am not a subscriber and I can’t get this to work. It this functionality in the public version of Corona or do I have to be a subscriber.
Regards
[import]uid: 171473 topic_id: 30962 reply_id: 330962[/import]
It is in the “public” version, absolutely. There is sample code for it in CoronaSDK > SampleCode > Interface > Widgets, if I recall correctly. [import]uid: 52491 topic_id: 30962 reply_id: 123859[/import]
It is in the “public” version, absolutely. There is sample code for it in CoronaSDK > SampleCode > Interface > Widgets, if I recall correctly. [import]uid: 52491 topic_id: 30962 reply_id: 123859[/import]
Hi Peach,
I need some help.
I am using a pickerwheel in my app to allow people to pick dates. Now I need it so that when they pick a date, it a appears onscreen in like a textbox, or something else.
For example, if you look at the calendar app in iOS, you can pick a date with the picker wheel. When you pick a date it appears onscreen.
This is what I need.
Here is my code:
--Date Picker
local function onButtonRelease( event )
-- set up the pickerWheel's columns
local columnData = {}
columnData[1] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }
columnData[1].alignment = "right"
columnData[1].width = 150
columnData[1].startIndex = monthIndex or 10
columnData[2] = {}
for i=1,31 do
columnData[2][i] = i
end
columnData[2].alignment = "center"
columnData[2].width = 60
columnData[2].startIndex = dayIndex or 25
columnData[3] = {}
for i=1,25 do
columnData[3][i] = i+2011
end
columnData[3].startIndex = yearIndex or 1
-- create pickerWheel widget
local picker = widget.newPickerWheel{
top=970,
font=native.systemFontBold,
columns=columnData,
}
-- onComplete listener for pickerWheel "slide up" transition
local function showDoneButton()
local function onDoneRelease( event )
-- extract selected rows from pickerWheel columns
local pickerValues = picker:getValues()
monthIndex = pickerValues[1].index
dayIndex = pickerValues[2].index
yearIndex = pickerValues[3].index
print( "Chosen date: " .. pickerValues[1].value .. " " .. pickerValues[2].value .. ", " .. pickerValues[3].value )
display.remove( picker )
picker = nil
display.remove( doneButton )
doneButton = nil
end
-- button below is local because of forward declaration defined earlier
doneButton = widget.newButton{
default = "Images/donebtn.png",
over = "Images/donebtn\_over.png",
width = 104,
height = 50,
left = 500,
top = 75,
onRelease = onDoneRelease
}
end
-- slider pickerWheel up into view
transition.to( picker, { time=800, y=740, transition=easing.inOutExpo, onComplete=showDoneButton } )
end
-- create button widget to show pickerWheel
local button = widget.newButton{
label = "Show Picker",
onRelease = onButtonRelease
}
group:insert( button )
button.x = 160
button.y = 300
Thanks!
-Landon [import]uid: 111492 topic_id: 30962 reply_id: 125798[/import]
Hi Landon,
Basically stated, you need to create text objects in advance of initializing the widget. These text objects will represent the onscreen display, and they can begin as blank (""). In your OnDoneRelease function, around line 44, update these values to the picker results using “object.text = [value]”. That’s about it basically. You can append all of the values into one text string/object if you wish, or update each element.
Brent [import]uid: 9747 topic_id: 30962 reply_id: 125891[/import]
Hi Peach,
I need some help.
I am using a pickerwheel in my app to allow people to pick dates. Now I need it so that when they pick a date, it a appears onscreen in like a textbox, or something else.
For example, if you look at the calendar app in iOS, you can pick a date with the picker wheel. When you pick a date it appears onscreen.
This is what I need.
Here is my code:
--Date Picker
local function onButtonRelease( event )
-- set up the pickerWheel's columns
local columnData = {}
columnData[1] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }
columnData[1].alignment = "right"
columnData[1].width = 150
columnData[1].startIndex = monthIndex or 10
columnData[2] = {}
for i=1,31 do
columnData[2][i] = i
end
columnData[2].alignment = "center"
columnData[2].width = 60
columnData[2].startIndex = dayIndex or 25
columnData[3] = {}
for i=1,25 do
columnData[3][i] = i+2011
end
columnData[3].startIndex = yearIndex or 1
-- create pickerWheel widget
local picker = widget.newPickerWheel{
top=970,
font=native.systemFontBold,
columns=columnData,
}
-- onComplete listener for pickerWheel "slide up" transition
local function showDoneButton()
local function onDoneRelease( event )
-- extract selected rows from pickerWheel columns
local pickerValues = picker:getValues()
monthIndex = pickerValues[1].index
dayIndex = pickerValues[2].index
yearIndex = pickerValues[3].index
print( "Chosen date: " .. pickerValues[1].value .. " " .. pickerValues[2].value .. ", " .. pickerValues[3].value )
display.remove( picker )
picker = nil
display.remove( doneButton )
doneButton = nil
end
-- button below is local because of forward declaration defined earlier
doneButton = widget.newButton{
default = "Images/donebtn.png",
over = "Images/donebtn\_over.png",
width = 104,
height = 50,
left = 500,
top = 75,
onRelease = onDoneRelease
}
end
-- slider pickerWheel up into view
transition.to( picker, { time=800, y=740, transition=easing.inOutExpo, onComplete=showDoneButton } )
end
-- create button widget to show pickerWheel
local button = widget.newButton{
label = "Show Picker",
onRelease = onButtonRelease
}
group:insert( button )
button.x = 160
button.y = 300
Thanks!
-Landon [import]uid: 111492 topic_id: 30962 reply_id: 125798[/import]
Hi Landon,
Basically stated, you need to create text objects in advance of initializing the widget. These text objects will represent the onscreen display, and they can begin as blank (""). In your OnDoneRelease function, around line 44, update these values to the picker results using “object.text = [value]”. That’s about it basically. You can append all of the values into one text string/object if you wish, or update each element.
Brent [import]uid: 9747 topic_id: 30962 reply_id: 125891[/import]