0

Recently I was building a channel containing some buttons, I was trying using https://sdkdocs.roku.com/display/sdkdoc/ButtonGroup. Since I tried to divide the buttons into two lines, so I tried two buttongroup in two lines. like:

button1 button2

button3 button4 button5

Here is my original code in xml:

<ButtonGroup layoutDirection =  "horiz" addItemSpacingAfterChild = "false" horizAlignment = "left">
    <Button
        id = "button1"
        text = "button1"/>
    <Button
        id = "Button2"
        text = "Button2"/>
</ButtonGroup>
<ButtonGroup layoutDirection =  "horiz" >
    <Button
        id = "Button3"
        text = "Button3"/>
    <Button
        id = "Button4"
        text = "Button4"/>
    <Button
        id = "Button5"
        text = "Button5"/>                          
</ButtonGroup>

How can I remove the auto focus of each of the buttongroup, Because I don't want to have to auto focus at button1 and button3 at the same time.

Here is my working environgment:

Roku2, Roku3, working with Eclipse Mars 2.0 for java developers.

Here is some of my problems:

Since ButtonGroup is extended from LayoutGroup. I found only the attributes from LayoutGroup work, like layoutDirection and addItemSpacingAfterChild. But the attributes in ButtonGroup don't work. Like I was trying to change the color of text, I was trying to change the maxwidth. None of them works. How can I remove auto focus and use buttongroup correctly?

Can anybody help with this problem?

Usman Maqbool
  • 3,351
  • 10
  • 31
  • 48

1 Answers1

2

You should set buttons as an array of strings into "buttons" field of ButtonGroup. Here is what you need:

<ButtonGroup
    id="buttonGroup1"
    layoutDirection="horiz"
    addItemSpacingAfterChild="false"
    horizAlignment="left"
    focusFootprintBitmapUri="pkg:/"
    buttons="[&quot;button1&quot;, &quot;button2&quot;]"/>
<ButtonGroup
    id="buttonGroup2"
    layoutDirection="horiz"
    translation="[0, 100]"
    focusFootprintBitmapUri="pkg:/"
    buttons="[&quot;button3&quot;, &quot;button4&quot;, &quot;button5&quot;]"/>

Also, you can set buttons from BrightScript code:

buttonGroup1 = m.top.findNode("buttonGroup1")
buttonGroup1.buttons = ["button1", "button2"]

Thus, ButtonGroup will automatically create and append Button nodes to itself, which you can later get via:

button = buttonGroup1.getChild(0)

Finally, to remove autofocus from unfocused buttons you can set into "focusFootprintBitmapUri" field invalid string. This is kind of a hack, but it works and I couldn't find a better way.

buttonGroup.focusFootprintBitmapUri = ""
Jess Bowers
  • 2,846
  • 1
  • 22
  • 42
Eugene Smoliy
  • 934
  • 4
  • 9
  • I tried another way for using button in buttongroup. ` `, and we can set attributed in the ` – terminator21 Apr 05 '16 at 12:49