Search code examples
rokubrightscript

What is the difference between active and setFocus() in bright script?


I'm new to Roku world, I'm writing the two textboxes. TextEditbox1 active = true to display a cursor and down key to press, Another texteditbox2 active = true that time texteditbox1 is hidden then Texteditbox2 cursor is displayed. The issue is that. The similar operation I perform with two-button using setFocus() instead of active. it's perfectly working. But I tried to maintain the down key and up key with two textboxes using the Active attribute. It is possible?

I Tried to below things.

TextEditBox1  active = true cursor is displayed

TextEditBox2 active = true cursor is displayed and TextEditBox1 cursor is hidden

I same operation with two-button it's working successfully.

Button1 setfocus true focus is available

Button2 setfocus true focus is available and Button1 setfocus is hidden

Solution

  • This is stupid BUT:

    • active only shows that blinking cursor in the TextEditBox

    when

    • setFocus() gives it actual focus, when TextEditBox processes keyPress event

    In my opinion, the only way to use it properly is to imitate focusing on that component, by setting active=true without really giving it, because it blocks all the key events. You might make a wrapper-component, which receives focus and then sets active=true without passing it down. And(for example) such component would show KeyboardDialog when the user presses the 'OK' button.

    UPD:

    clearOnDownKey="false" might save you from this pain