Here it is stripped down. The only way out of the keyboard screen is to press back, but the real code uses the screen button.
Sub RunUserInterface(aa as Object)
canvas = CreateObject("roImageCanvas")
port = CreateObject("roMessagePort")
canvas.SetMessagePort(port)
canvas.SetLayer(0, {Color:"#FF800000"})
canvas.SetRequireAllImagesToDraw(false)
canvas.Show()
kbport = CreateObject("roMessagePort")
screen = CreateObject("roKeyboardScreen")
screen.SetMessagePort(kbport)
screen.SetDisplayText("Enter number from 1 to 1000")
screen.SetMaxLength(4)
screen.AddButton(1,"Finished")
nbr = rnd(1000)
while true
screen.SetText(nbr.toStr())
screen.Show()
msg = wait(0,kbport)
if type(msg) = "roKeyboardScreenEvent" then
if msg.isScreenClosed() then
print "got screen closed"
exit while
end if
end if
end while
' eat possible Back button
msg = wait(100,port)
if type(msg) = "roImageCanvasEvent" then
if msg.isRemoteKeyPressed() then
print "Key Pressed - " ; msg.GetIndex()
end if
end if
End Sub
Just to verify, I tried using the same message port for both screens and the "roImageCanvasEvent" still occurs.
-JT
Roku Community Streaming Expert
Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.
I am not a Roku employee.