Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
destruk
Level 10

Possible delay timing issue? - Roku2

I've noticed this a few times on various channel projects I've been working on.
For the roKeyboard Screen and roPinEntryDialog screen, when I call the screen and return the value to the calling function, if I don't print the returned value it sometimes fails the immediate check on the next line of code.


Function CaptureEmail() As String
screen=CreateObject("roKeyboardScreen")
port=CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.SetDisplayText("Enter your email address")
screen.SetMaxLength(100)
Screen.AddButton(1,"Done")
Screen.AddButton(2,"Back")
Screen.Show()
While TRUE
msg=Wait(0,port)
If Type(msg)="roKeyboardScreenEvent"
If msg.isButtonPressed()
Print"Button pressed: ";msg.GetIndex()
If msg.GetIndex()=1
entry=screen.GetText()
entry=entry.trim()
If len(entry)>0
Return lcase(entry)
End If
Else If msg.GetIndex()=2
Return "invalid"
End If
End If
End If
End While
End Function



email=CaptureEmail()
print email
If email<>"invalid"


Sample code --

Function CaptureCode() As String
screen=CreateObject("roPinEntryDialog")
port=CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.SetNumPinEntryFields(5)
screen.SetTitle("Enter Code")
Screen.AddButton(1,"Done")
Screen.AddButton(2,"Back")
Screen.Show()
While TRUE
msg=Wait(0,port)
If Type(msg)="roPinEntryDialogEvent"
If msg.isButtonPressed()
Print"Button pressed: ";msg.GetIndex()
If msg.GetIndex()=1
If len(screen.Pin())>0
Return screen.Pin()
End If
Else If msg.GetIndex()=2
Return "invalid"
End If
End If
End If
End While
End Function


The calling function has this

code=CaptureCode()
print code
If code<>"invalid"


Sometimes it works without printing the code, sometimes it fails without printing the code. By printing the code every time it appears to operate correctly.
I'm confused why it would do this, and printing it takes care of the issue, so I just thought it'd be good to report it here. Without printing the email after email=CaptureEmail() it just sits there when it is returned.
0 Kudos
1 REPLY 1\
bgardella
Level 7

Re: Possible delay timing issue? - Roku2

I am finding that roPinEntryDialog will not display sometimes when you call "Show()"

Is this related?
0 Kudos