Ok, so are you saying that I can have date: month,date, year as well as time:hour, minute, AM/PM??? [import]uid: 69302 topic_id: 30437 reply_id: 122235[/import]
Yes, but it will be tight. You’re looking at 6 columns of data, so you probably will have to use 3 letter month abbreviations. It’s tough to make sense out of the sample code, but I’ve pulled out the bits for you. Do this for your column data:
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 3
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+1990
end
columnData[3].startIndex = yearIndex or 20
-- create pickerWheel widget
local picker = widget.newPickerWheel{
top=480,
font=native.systemFontBold,
columns=columnData,
}
Now that just does, Mon, Day, Year, but you can add the other 3 colums following the pattern above.
[import]uid: 19626 topic_id: 30437 reply_id: 122240[/import]
@robmiracle- just a quick question. I think I have read every API, is it even possible to have “00” as the start count of the time? Because the way it looks it doesn’t seem possible. [import]uid: 69302 topic_id: 30437 reply_id: 122245[/import]
it does not recognize the variable “widget”.
Most likely you created “widget” as a local variable outside of the scope of where the error occurs. So I would start first by looking at where you first created “widget”. [import]uid: 94868 topic_id: 30437 reply_id: 121930[/import]
You did not do a
local widget=require(“widget”)
somewhere before your line [import]uid: 160496 topic_id: 30437 reply_id: 121931[/import]
Or you did
widget = “fred”
or
widget = 10
or
widget = {}
something to overwrite the widget object.
[import]uid: 19626 topic_id: 30437 reply_id: 121932[/import]
So what lua file should I be placing local widget=require(“widget”)?
That looks as thought that is my problem. because other than what I posted that is the only place I mentioned the widget. [import]uid: 69302 topic_id: 30437 reply_id: 122022[/import]
WARNING: The pickerWheel widget requires a visual theme. Use widget.setTheme(). ? What is meant by visual theme? Is it asking me to use a image? [import]uid: 69302 topic_id: 30437 reply_id: 122029[/import]
At the top of the file in which the error occurs. [import]uid: 160496 topic_id: 30437 reply_id: 122038[/import]
ok mike470- i am not sure what are saying to do. [import]uid: 69302 topic_id: 30437 reply_id: 122039[/import]
add this line:
local widget=require(“widget”)
as one of the first lines of the file in which you have the error happening for these two lines:
– Create the picker widget:
myPicker = widget.newPickerWheel{ preset=“usDate”, startDay=19, startMonth=2, startYear=2012 }
if you do that, then widget variable will not be nil and the error won’t happen. [import]uid: 160496 topic_id: 30437 reply_id: 122044[/import]
ok mike470 I believed I fixed that error. but now I have:Runtime error
module ‘pickerWheel’ not found:resource (pickerWheel.lu) does not exist in archive
no field package.preload[‘pickerWheel’]
no file ‘/Users/babybeanie98/Desktop/Forgetful Memory/pickerWheel.lua’
no file ‘/Volumes/CoronaSDK/CoronaSDK/Corona Simulator.app/Contents/Resources/pickerWheel.lua’
no file ‘/Volumes/CoronaSDK/CoronaSDK/Corona Simulator.app/Contents/Resources/pickerWheel.blu’
stack traceback:
Not sure why because I do have/had a pickerWheel.lua but still got the error [import]uid: 69302 topic_id: 30437 reply_id: 122135[/import]
anybody know why I am getting message??? [import]uid: 69302 topic_id: 30437 reply_id: 122196[/import]
Can we see some code?
[import]uid: 19626 topic_id: 30437 reply_id: 122198[/import]
Of course you can. So. I wasn’t sure if I should make a a separate file for if or add it to my level1 or menu lua. But I tried both and still got the same error.
[code] widget.newPickerWheel( “pickerWheel” )
widget.setTheme(“widget”)
– localize a couple variables prior to use
local myPicker, doneButton
– button event handler
local onDone = function( event )
– get values from picker wheel
local m = myPicker.col1.value
local d = myPicker.col2.value
local y = myPicker.col3.value
– Print the results to the terminal:
print( m … " " … d … ", " … y )
– remove the button
display.remove( doneButton )
doneButton = nil
– remove the picker wheel
display.remove( myPicker )
myPicker = nil
end
– Create the picker widget:
myPicker = widget.newPickerWheel{ preset=“usDate”, startDay=19, startMonth=2, startYear=2011 }
widget.setTheme(“pickerWheel”)
local widget=require(“myPicker”)
– Place picker wheel at bottom of iPhone screen:
myPicker.y = display.contentHeight - myPicker.height
– Create a “Done” ui button widget to capture picker selection:
doneButton = widget.newButton{ label=“Done”, onRelease=onDone }
doneButton:setReferencePoint( display.CenterRightReferencePoint )
doneButton.x = display.contentWidth - 5
doneButton.y = 22
[/code]
[import]uid: 69302 topic_id: 30437 reply_id: 122204[/import]
While I have you online. When I add buttons to my apps, what determines where I put the file for that? [import]uid: 69302 topic_id: 30437 reply_id: 122205[/import]
Things have to happen in a certain order. For instance, you can’t reference the object “widget” until you’ve included it.
You need to read the documentation on these things before you use them:
http://docs.coronalabs.com/api/library/widget/newPickerWheel.html
http://docs.coronalabs.com/api/library/widget/setTheme.html
So basically your first line should be:
local widget = require(“widget”)
You’re current line one may be creating a picker wheel but how are you going to reference it? You never store the pickerWheel any where. That next line should be:
local myPickerWheel = widget.newPickerWheel( someTableOfOptions )
But you’ve not created that table of options yet.
Here is a picker wheel setup from one of my projects… Study it.
local widget = require("widget")
widget.setTheme("theme\_ios")
-- there is currently only one theme, theme\_ios. You should copy it from one of the sample projects
-- the whole folder goes into the folder with your main.lua
local columnRows = {"Item 1", "Item 2", "Item 3", "Item 4"}
local columnData = {} -- table that holds information about the column in the pickerWheel
columnData[1] = columnRows -- the data
columnData[1].alignment = "left" -- do you want it left aligned, center aligned or right aligned?
columnData[1].width = 148 -- width of the column
columnData[1].startIndex = 1 -- where in the list to start.
local picker = widget.newPickerWheel{
id="msgPicker",
font="Helvetica-Bold",
fontSize=18,
top=64 + display.statusBarHeight + 20,
columns=columnData
}
As for the buttons, it looks like you’re using the widget.button maker and it doesn’t need any external files.
[import]uid: 19626 topic_id: 30437 reply_id: 122207[/import]
Believe it or not I have read the api you listed that is how I got as far as I did and got the error I got. But you said that my second line should be: local myPickerWheel = widget.newPickerWheel( someTableOfOptions )
But looking at the sample of your pickerwheel why do you not have it? and reading line 3 of your code as well does not seem to be making much of a difference [import]uid: 69302 topic_id: 30437 reply_id: 122215[/import]
I can see where I was confusing. My point is that you can’t use the picker wheel before you define it. You can’t set the theme until you’re loaded the widget library in.
There are quite a few things you need to do to make this work that isn’t technically part of the picker wheel, like setting up your data. The columnData table could be passed directly to the widget by putting the table inside the call. It’s just cleaner code to break that table out of the widget call.
So its:
widget = require “widget”
widget.setTheme
myPicker = widget.newPickerWheel(some options and settings)
In your case you’re using a predefined setting so you don’t need the databits.
[import]uid: 19626 topic_id: 30437 reply_id: 122222[/import]
I was under the impression that once I get the code properly I would be able to set up my data. If you are speaking about what I want my picker to include I was just doing the date and time. Can I not do this after I get rid of the error code?
and reading the api references, the some options and settings refers to the id, width, height, font. correct? [import]uid: 69302 topic_id: 30437 reply_id: 122225[/import]