btpoole
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2017
01:51 PM
How to get Column Index and Row Index in Markupgrid
Not sure if I am overlooking this in the docs but can't seem to figure out how to get the column index and row index of a selected item in a markupgrid, not the itemfoucsed. From what I understand the GetIndex() and GetData() doesn't work the same with a markupgrid. Any help appreciated.
8 REPLIES 8
btpoole
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2017
05:20 AM
Re: How to get Column Index and Row Index in Markupgrid
Surely there's a way to get the column index and row index of a focused item in a markupgrid.
btpoole
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2017
04:28 AM
Re: How to get Column Index and Row Index in Markupgrid
Anybody??
Veeta
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2017
08:27 AM
Re: How to get Column Index and Row Index in Markupgrid
Just had a look at the docs and it seemed like something was missing so i tried it out with the SceneGraphXMLTutorial code.
Markupgrid is different from, say, RowList in that it doesn't map 2D data and give 2D indices into that data. Rather, it takes a linear list of data and it just lays out that linear list on screen by wrapping based on the value of numColumns.
So your row and column would be
If you use the sections dividers, i don't have an answer there. You'd have to account for empty places in the grid as you encountered each section divider. In that case I would personally use a different component such as RowList.
Markupgrid is different from, say, RowList in that it doesn't map 2D data and give 2D indices into that data. Rather, it takes a linear list of data and it just lays out that linear list on screen by wrapping based on the value of numColumns.
So your row and column would be
rowFocused = itemFocused \ numColumns
columnFocused = itemFocused MOD numColumns
If you use the sections dividers, i don't have an answer there. You'd have to account for empty places in the grid as you encountered each section divider. In that case I would personally use a different component such as RowList.
btpoole
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2017
09:11 AM
Re: How to get Column Index and Row Index in Markupgrid
"Veeta" wrote:
Just had a look at the docs and it seemed like something was missing so i tried it out with the SceneGraphXMLTutorial code.
Markupgrid is different from, say, RowList in that it doesn't map 2D data and give 2D indices into that data. Rather, it takes a linear list of data and it just lays out that linear list on screen by wrapping based on the value of numColumns.
So your row and column would berowFocused = itemFocused \ numColumns
columnFocused = itemFocused MOD numColumns
If you use the sections dividers, i don't have an answer there. You'd have to account for empty places in the grid as you encountered each section divider. In that case I would personally use a different component such as RowList.
Thanks a ton. Had hoped I was just overlooking something in docs. I was able to figure out the rowFocused calculation but was having a heck of time on the column part. Excuse me for sounding dumb but was is MOD? I don't seem to find that in docs either.
Veeta
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2017
09:47 AM
Re: How to get Column Index and Row Index in Markupgrid
MOD is modulo https://en.wikipedia.org/wiki/Modulo_operation
btpoole
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2017
09:51 AM
Re: How to get Column Index and Row Index in Markupgrid
Thank you, I thought maybe it was something specific to Brightscript.

marcelo_cabral
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2017
11:39 PM
Re: How to get Column Index and Row Index in Markupgrid
I had a similar issue with MarkupGrid that only returns the index on itemFocused property, even when you have multiple sections.
My solution was to create an index array to easily access later the [section, index].
Then on the event to get the focus you just use this way:
My solution was to create an index array to easily access later the [section, index].
contentIndex = []
for s = 0 to m.top.content.getChildCount() - 1
for i = 0 to m.top.content.getChild(t).getChildCount() - 1
contentIndex.Push([s,i])
next
next
m.top.contentIndex = contentIndex
Then on the event to get the focus you just use this way:
index = m.top.contentIndex[itemFocused]
focusedContent = m.top.content.getChild(index[0]).getChild(index[1])
Bhavya
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2018
12:05 AM
Re: How to get Column Index and Row Index in Markupgrid
"marcelo.cabral" wrote:
I had a similar issue with MarkupGrid that only returns the index on itemFocused property, even when you have multiple sections.
My solution was to create an index array to easily access later the [section, index].contentIndex = []
for s = 0 to m.top.content.getChildCount() - 1
for i = 0 to m.top.content.getChild(t).getChildCount() - 1
contentIndex.Push([s,i])
next
next
m.top.contentIndex = contentIndex
Then on the event to get the focus you just use this way:index = m.top.contentIndex[itemFocused]
focusedContent = m.top.content.getChild(index[0]).getChild(index[1])
Great man. Thanks alot. your solution worked.