2

This is the smallest snippet I've been able to get to reproduce the issue.

Sub Main()
    u = getStringFromKeyboard("Enter username")
    p = getStringFromKeyboard("Enter password")
End Sub

Function getStringFromKeyboard(message = "" As String) As String
    result = ""
    port = CreateObject("roMessagePort")
    screen = CreateObject("roKeyboardScreen")
    screen.SetMessagePort(port)
    screen.SetDisplayText(message)
    screen.AddButton(1, "OK")
    screen.Show()
    while true
        print "waiting..."
        msg = wait(0, port)
        print "done waiting"
        if type(msg) = "roKeyboardScreenEvent" then
            if msg.GetIndex() = 1 then
                result = screen.GetText()
                exit while
            end if
        end if
    end while
    screen.Close()
    return result
End Function

The Roku will prompt correctly for the username, but will just exit to the main menu before prompting for the password. The debug output indicates that the app is borking on the second call to wait():

waiting...
done waiting
waiting...

This is SDK v4.1 and OS v4.2.1006.

Anybody have an idea what is going on?

Alex Howansky
  • 50,515
  • 8
  • 78
  • 98
  • There are zero other questions on SO about the Roku or their BrightScript language. You're probably going to be better off [posting on their dev forums](http://forums.roku.com/viewforum.php?f=34) – Charles Feb 22 '12 at 03:05
  • 2
    Heh yeah I did that too, but I figured every tag has to start somewhere... :) – Alex Howansky Feb 22 '12 at 14:23

1 Answers1

5

Answer from user gonzotek on the Roku developer forums:

Create a facade screen. The roku exits the app immediately after the last screen is closed. You create the first keyboard screen and also close it in the getStringFromKeyboard function, and since there are no other screens open at that moment, that's when the Roku kills the app. See RokuKevin's explanation here: viewtopic.php?p=162550#p162550 (note: he refers to 'screen flickering', which may have been true when he wrote it, but nowadays it's a requirement to have a screen always stuck open at the back of your stack for the life of your app: viewtopic.php?p=321402#p321402).

Alex Howansky
  • 50,515
  • 8
  • 78
  • 98