[Edited to reflect I don't think this is a bug, based on TheEndless' response below, and to change mentions of "roDetailScreen" to "roSpringboardScreen"]
The following subroutine demonstrates a bug I think that is different from
this other one.
The bug here is when opening an roSpringboardScreenon top of a double-buffered roScreen. After closing the roSpringboardScreen, the code requires an extra sleep/swapbuffers in order to redraw the screen as expected.
A sleep of 1 does not work (on my Roku 2 XS), but a sleep of 10 does. I believe neither the sleep nor the extra SwapBuffers should be necessary.
' Demonstrates a bug in redrawing an roScreen after the call/closing of an roSpringboardScreencomponent.
' Test on a Roku 2 XS, Software version 4.8 - build 1178
Sub roScreenBugDemo()
codes = bslUniversalControlEventCodes()
rscreen=CreateObject("roScreen",true)
msgport = CreateObject("roMessagePort")
rscreen.SetPort(msgport)
while (true)
' Draw a blue background, wait for OK button
rscreen.Clear(&h0000FFFF)
rscreen.SwapBuffers()
while (true)
msg=wait(0, msgport) ' wait for OK button
if type(msg)="roUniversalControlEvent" then
print "**** UniversalControl Event Int ";msg.GetInt()
if msg.GetInt()=codes.BUTTON_SELECT_PRESSED then 'ok button pressed
exit while
end if
end if
end while
' At this point, the OK button has been pressed
' So let's create the springboard with two choices.
' The user can select to exit the screenboard normally, or with the extra sleep/swapbuffers
dscreen = CreateObject("roSpringboardScreen")
dscreen.SetDescriptionStyle("generic")
dscreen.SetPosterStyle("rounded-square-generic")
dscreen.AddButton(0,"Ok")
dscreen.AddButton(1,"With Extra SwapBuffers")
dscreen.SetContent({Description:"Press OK, and you then can't move the button, (we'll be in the roScreen event loop). And if you press 'OK' again, then you'll see a 'new' detailscreen in which you can move the cursor."})
port = CreateObject("roMessagePort")
dscreen.SetMessagePort(port)
dscreen.Show()
while true
extra = false
msg = wait(0, port)
if msg.isScreenClosed() then
exit while
else if msg.isButtonPressed()
print "msg: "; msg.GetMessage(); "idx: "; msg.GetIndex()
if (msg.GetIndex() = 0 )
exit while
else if (msg.GetIndex() = 1 )
extra = true
exit while
end if
endif
end while
dscreen.Close()
if ( extra )
' If this sleep/swapbuffers is NOT called, then the detailscreen remains visible
' At that point, you can't move the button, and if you press "OK again, then you see a "new"
' detailscreen in which you can move the cursor.
' This error points to the clear/swapbuffers at the beginning of the event loop
' are ineffective without these two statements:
sleep(100) ' sleep(1) isn't apparently long enough for the Roku 2 XS
rscreen.SwapBuffers() ' both the sleep and this extra SwapBuffers is required, I don't know why
' Note that after this loops, the first thing we do is redraw and swapbuffers again.
end if
end while
End Sub