Making a date entry page for Roku?
I'm working on a Roku app and we need the user's date of birth. Trying not to get too complicated at the syntactic end (so would rather not just have a textbox where the user can type whatever they want). I have looked into the usage roPinEntryDialog
, but unfortunately I think this is only for entering billing information. I see that roDateTime
is a thing, but it looks like it only gets the current date and doesn't have any type of inputs for it.
Any ideas or help?
Thank!
source to share
As a result, I used a regular text keyboard and validated the input with a regular expression:
getText: function(ageValidate as Boolean, defaultText as String, displayText as String) as String
screen = CreateObject("roKeyboardScreen")
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.SetDisplayText(displayText)
screen.SetText(defaultText)
screen.SetMaxLength(100)
screen.AddButton(1, "done")
screen.AddButton(2, "back")
screen.Show()
while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roKeyboardScreenEvent"
if msg.isScreenClosed()
return ""
else if msg.isButtonPressed() then
if ageValidate = true AND m.isValidDate(text) = false then
"Invalid Input", "Input your birthdate in the format MMDDYYYY", "okay")
else if text = invalid OR text = ""
showUserDialog("Error"), "no input", "okay")
else
screen.Close()
return text
end if
else if msg.GetIndex() = 2
screen.Close()
return ""
end if
end if
end if
end while
end function
isValidDate: function(date as String) as Boolean
return CreateObject("roRegex", "(0[1-9]|1[012])[-.]?(0[1-9]|[12][0-9]|3[01])[-.]?(19|20)[0-9]{2}", "i").IsMatch(date)
end function
source to share
What you can do depends on whether you are recording the app SDK1 (older but simpler components that are deprecated now) or RSG (Roku Scene Graph is a newer, more complex way to implement).
If using RSG, I would think LabelList is a good start to implement something similar to the iOS UIDatePicker . For example. with the remote user Up selects the month, then press Right to navigate to the Day column, then Right to the year list.
source to share