Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
kyleabaker
Visitor

Change button text on SpringboardScreen without losing focus

I have a SpringboardScreen with several buttons, some perform toggle functions where I'd like to change the text from "Option On" to "Option Off". I've determined that I can clear the buttons and add them again with correct text, however, the UseStableFocus(true) setting seems to be ignored since the buttons were cleared. Ultimately I would like to change the text of a button without moving off of the selected button. Am I missing a step here?
0 Kudos
3 REPLIES 3
TheEndless
Channel Surfer

Re: Change button text on SpringboardScreen without losing f

UseStableFocus() should work, even with clearing and re-adding the buttons. That's how navigating left and right work. Can you share the code you're using to reset the buttons?
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
kyleabaker
Visitor

Re: Change button text on SpringboardScreen without losing f

Below is a skeleton of the code I'm working with. Is this an invalid approach?


' Code to initialize springboard here
'....

springBoard.UseStableFocus(true)

regenerateSpringBoardButtons:
springBoard.ClearButtons()

If (isToggledOn = true) Then
springBoard.AddButton(1,"Option On")
Else
springBoard.AddButton(1,"Option Off")
End If

springBoard.SetContent(o)
springBoard.Show()
While True
msg = wait(0, port)
If msg.isScreenClosed() Then
Return -1
Elseif msg.isButtonPressed()
print "msg: "; msg.GetMessage(); "idx: "; msg.GetIndex()
idx = msg.GetIndex()

If (idx = 1) Then
updateOptionToggleState()
goto regenerateSpringBoardButtons
End If
Endif
End While
0 Kudos
kyleabaker
Visitor

Re: Change button text on SpringboardScreen without losing f

Resolved

For anyone seeing this issue in the future, I've actually resolved this issue now by using AllowUpdates() which I wasn't previously using. You may also notice that I pull the SetContent out of the GoTo loop, that was just because it wasn't necessary to set each time. See corrected code below:


' Code to initialize springboard here
'....

springBoard.UseStableFocus(true)
springBoard.SetContent(o)

regenerateSpringBoardButtons:
springBoard.AllowUpdates(false)
springBoard.ClearButtons()

If (isToggledOn = true) Then
springBoard.AddButton(1,"Option On")
Else
springBoard.AddButton(1,"Option Off")
End If

springBoard.AllowUpdates(true)
springBoard.Show()
While True
msg = wait(0, port)
If msg.isScreenClosed() Then
Return -1
Elseif msg.isButtonPressed()
print "msg: "; msg.GetMessage(); "idx: "; msg.GetIndex()
idx = msg.GetIndex()

If (idx = 1) Then
updateOptionToggleState()
goto regenerateSpringBoardButtons
End If
Endif
End While
0 Kudos