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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MarkupGrid fixedLayout true "Ghosts" Cells

Hi everyone!,  I have a trouble with MarkupGrid fixedlayout, this is a example project where I reproduce the problem. The purpose of the project is to show a grid with two rows with 5 items each. This works if you have numColumns=5 (property value assigned on SimpleMarkupListScene.brs ln 16) . If I set numColumns=4, I expect that the last column will hide and I can scroll horizontally to it (I'm wrong?, this happens if I add multiple items on one row, just one row) but I got errors about cells already occupied. I added some comments on the code about the issues.

Let me know what you think, Thanks!

function init()
    m.simpleMarkupGrid ="SimpleMarkupGrid")
    m.simpleMarkupGrid.content = getGridData()
end function

function onKeyEvent(key as String, press as Boolean) as Boolean
    handled = false
    return handled
end function

function getGridData() as object

    data = CreateObject("roSGNode", "ContentNode")

    m.simpleMarkupGrid.numColumns = 5
    'if we have rows = 1, items = 10 and numColumns = 5 we can scroll horizontally
    'if we have rows = 2, items = 5 and numColumns = 4 we have "cell was already occupied" errors
    'if we have rows = 2, items = 5 and numColumns = 5 we can see a 2x5 grid    
    rows = 2
    items = 5

    for i=0 to rows-1
        for j=0 to items -1
            dataItem = data.CreateChild("ItemData")
            dataItem.text = stri(j) + "," + stri(i)
            dataItem.X = j
            dataItem.Y = i
            dataItem.W = 1
            dataItem.H = 1
        end for
    end for

    ' I can't add an item on the row [0,1]  or [1,1], etc, because there is a "cell" already there if the numColumns is 4, Why is this?
'    ------ Running dev 'Simple MarkupList' main ------
'    ** Error - ArrayGrid: Fixed Layout cell was already occupied
'        cell 4, current item: 4, new item: 5
'        Row (Y): 1 Column (X): 0 Width (W):1 Height (H): 1

    return data
end function

<?xml version="1.0" encoding="utf-8" ?>

<component name="SimpleMarkupListScene" extends="Scene" >

<script type="text/brightscript" uri="pkg:/components/SimpleMarkupListScene.brs" />

  drawFocusFeedback = "false"


<?xml version="1.0" encoding="utf-8" ?>

<component name="ItemData" extends="ContentNode">

  <field id="text" type="string" />


<?xml version="1.0" encoding="utf-8" ?>

<component name="Item" extends="Group">

  <field id="itemContent" type="node" onChange="itemContentChanged"/>
  <field id = "focusPercent" type = "float" onChange = "showfocus"/>
  <field id = "rowFocusPercent" type = "float" onChange = "showrowfocus"/>

<script type="text/brightscript" >
  function itemContentChanged()
    itemData =

    m.text.text = itemData.text

    m.boundRect ="boundingRect")
    m.boundRect.width *= itemData.W
  end function

  function init()
    m.text ="text")
  end function

  function showfocus()
   if = 1 then
         m.boundRect.opacity = 1
         if > .5 then
            m.boundRect.opacity =
            m.boundRect.opacity = .5
         end if
      end if
  end function

  function showrowfocus()

  end function

         <Label id="text"

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.