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: 
EnTerr
Roku Guru

How to update button text?

I am using roSpringboardScreen and want to update the text of one of the buttons when clicked. Hypothetically let's say I want the button text to show a number/counter that increases with every press - or an "on"/"off" alternate text. How can i do that?

Here is how my flea of thought has been hopping so far:
  1. Maybe i can update it? No, there is no UpdateButton() method.

  2. Maybe AddButton() with the same id# will update the text? No, it adds new button at the end

  3. Maybe i'll just .ClearButtons() and then .AddButton() them again. And that almost worked - "almost" because after such acrobatics the current button loses the focus (naturally, the selection gets reset to the first button).

  4. To address C, maybe i can manually set the focus? No, no method SetFocusedMenuItem() here.

  5. Ok, so i am open minded - maybe i have to use roMessageDialog instead, which seems the only one with UpdateButton() or SetFocusedMenuItem(). Alas, this one does not seem to have a way to add an image - AddGraphic() or alike.

So, how can i do that?
I want
  1. a button that can change its text when pressed and does not lose focus because of that

  2. inside a classic component (non-scenical) that can have an image
0 Kudos
2 REPLIES 2
renojim
Community Streaming Expert

Re: How to update button text?

Did you use screen.UseStableFocus(true) when your flea hopped to C? I also surround the whole process in screen.AllowUpdates(false)/screen.AllowUpdates(true).

-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.
0 Kudos
EnTerr
Roku Guru

Re: How to update button text?

I used UseStableFocus(), yes - but it did not help (perhaps because i do clear()?).

In "LED Time & Weather" Settings you do what i am trying to - say in "Information options" buttons flip between enable/disable and focus is retained - what kind of magic is that?

PS. <censor> me, toggling scr.AllowUpdates() did it!
"The Roku works in mysterious ways"...
Thank you Jim, you are sanity saver!
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.