Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
EnTerr
Level 8

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
renojim
Level 8

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
0 Kudos
EnTerr
Level 8

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