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: 

Grid Screen Development And Documentation

I am trying to learn and develop a grid screen for an application/channel. Like most Roku Brightscript language documentation, that for roGridScreen is drastically minimal.

The point specifically I am at now is what property do I set for each record in order to show an image?

Also, where is the full documentation with all the attributes available for roGridScreen?

Thanks.
שלום חבר

Dean at the School of Truth: a part of Autodidact University.

"A programmer is just a tool which converts caffeine into code"
Temet nosce
Vi Veri Veniversum Vivus Vici
Si vis pacem, para bellum
0 Kudos
20 Replies
destruk
Level 10

Re: Grid Screen Development And Documentation

0 Kudos

Re: Grid Screen Development And Documentation

Thanks for the links, but the roGridScreen link I've already been to. The example and/or documentation doesn't list how to set the image attribute nor is there documentation on the other attributes either.
שלום חבר

Dean at the School of Truth: a part of Autodidact University.

"A programmer is just a tool which converts caffeine into code"
Temet nosce
Vi Veri Veniversum Vivus Vici
Si vis pacem, para bellum
0 Kudos
TheEndless
Level 7

Re: Grid Screen Development And Documentation

All content metadata is documented here: http://sdkdocs.roku.com/display/sdkdoc/ ... +Meta-Data
For posters, you'd use HDPosterUrl and SDPosterUrl, the same as you do for most other screens.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos

Re: Grid Screen Development And Documentation

Aaahhh, now there we go! Thanks!

Perhaps such an explanation and link could be added to the documentation for each screen.
שלום חבר

Dean at the School of Truth: a part of Autodidact University.

"A programmer is just a tool which converts caffeine into code"
Temet nosce
Vi Veri Veniversum Vivus Vici
Si vis pacem, para bellum
0 Kudos

Re: Grid Screen Development And Documentation

Now for the next step. Once an item's information is set and the app is running, when you click on the item/poster, how do you retrieve the associated information for that item? I haven't found anything in the documentation for this.


Function Main()
port = CreateObject("roMessagePort")
grid = CreateObject("roGridScreen")
grid.SetMessagePort(port)
rowTitles = CreateObject("roArray", 10, true)
for j = 0 to 10
rowTitles.Push("[Row Title " + j.toStr() + " ] ")
end for
grid.SetupLists(rowTitles.Count())
grid.SetListNames(rowTitles)
for j = 0 to 10
list = CreateObject("roArray", 10, true)
for i = 0 to 10
o = CreateObject("roAssociativeArray")
o.ContentType = "episode"
o.Title = "[Title" + i.toStr() + "]"
o.ShortDescriptionLine1 = "[ShortDescriptionLine1]"
o.ShortDescriptionLine2 = "[ShortDescriptionLine2]"
o.Description = ""
o.Description = "[Description] "
o.Rating = "NR"
o.StarRating = "75"
o.ReleaseDate = "[<mm/dd/yyyy]"
o.Length = 5400
o.Actors = []
o.Actors.Push("[Actor1]")
o.Actors.Push("[Actor2]")
o.Actors.Push("[Actor3]")
o.Director = "[Director]"
list.Push(o)
end for
grid.SetContentList(j, list)
end for
grid.Show()
while true
msg = wait(0, port)
if type(msg) = "roGridScreenEvent" then
if msg.isScreenClosed() then
return -1
elseif msg.isListItemFocused()
print "Focused msg: ";msg.GetMessage();"row: ";msg.GetIndex();
print " col: ";msg.GetData()
elseif msg.isListItemSelected()
print "Selected msg: ";msg.GetMessage();"row: ";msg.GetIndex();
print " col: ";msg.GetData()
endif
endif
end while
End Function


Given the above sample code from the roGridScreen documentation, once an item is selected, how do you get each piece of information that has been set for that item? Also, can you just take the entire item of information as an object?
שלום חבר

Dean at the School of Truth: a part of Autodidact University.

"A programmer is just a tool which converts caffeine into code"
Temet nosce
Vi Veri Veniversum Vivus Vici
Si vis pacem, para bellum
0 Kudos
Roku Employee
Roku Employee

Re: Grid Screen Development And Documentation

You can look at a grid as an array of arrays of associative arrays. Each AA looks something like this:

aa={ ContentType : "episode"
Title : "[Title" + i.toStr() + "]"
ShortDescriptionLine1 : "[ShortDescriptionLine1]"
ShortDescriptionLine2 : "[ShortDescriptionLine2]"
Description : ""
Description : "[Description] "
Rating : "NR"
StarRating : "75"
ReleaseDate : "[<mm/dd/yyyy]"
Length : 5400
Actors : []
Actors.Push("[Actor1]")
Actors.Push("[Actor2]")
Actors.Push("[Actor3]")
Director : "[Director]"
}

Each row array looks something like this:

row=[aa,aa,aa,aa,aa,aa,aa,aa,aa]


and the top level, array of arrays of associative arrays looks like this:

grid=[row
row
row
row
row
row
row]


Note that you can delimit an array with either a comma or a carriage return, so I used that method for the last one so you can visualize it.

When the user clicks on an item in the grid, the isListItemSelected() property of the roGridScreenEvent is true and the index values of that event are then available through msg.getIndex() for the horizontal position and msg.getData() for the vertical position. You can then retrieve video information from the arrays using those values:

VideoItem=grid[msg.getdata()][msg.getindex()]


or

selectedRow=grid[msg.getdata()]
selectedvideo=selectedRow[msg.getindex()]


Because you know that isListItemSelected() is true, you know that the user has clicked on an item, and now that you've extracted the video information, you just need to call your Springboard function or video playback function with selectedVideo as the parameter.

Note that it is a good practice to create your grid as an array first, and then use it to set the rows of the grid - that way you can easily rebuild the grid after you've closed it (a necessity on legacy firmware before opening another screen) without having to hit your server again and reparse the data.

Hope that helps,

- Joel
0 Kudos

Re: Grid Screen Development And Documentation

And this, my friend, is why you are awesome. Not only example code, but also explanations, reasonings, and tips.

I vote for your answer to be included in the official documentation for roGridScreen at http://sdkdocs.roku.com/display/sdkdoc/roGridScreen and/or for you to write the documentation for the Roku BrightScript.

Thanks again!
שלום חבר

Dean at the School of Truth: a part of Autodidact University.

"A programmer is just a tool which converts caffeine into code"
Temet nosce
Vi Veri Veniversum Vivus Vici
Si vis pacem, para bellum
0 Kudos

Re: Grid Screen Development And Documentation

Alright, so I tried what you suggested with


title = grid[msg.GetData()][msg.GetIndex()].Title.gettext()
print "Title => "+title


But it's throwing an error


Array operation attempted on variable not DIM'd. (runtime error &he7) in ...TZPco/pkg:/source/appMain.brs(91)
091: title = grid[msg.GetData()][msg.GetIndex()].Title.gettext()


Also tried "tostr()" in place of "gettext()", but produced the same error.
שלום חבר

Dean at the School of Truth: a part of Autodidact University.

"A programmer is just a tool which converts caffeine into code"
Temet nosce
Vi Veri Veniversum Vivus Vici
Si vis pacem, para bellum
0 Kudos

Re: Grid Screen Development And Documentation

Ok, so I have tried every variation that I can think of. I have worked with the suggestions that have been put forth so far. I have searched the Google-sphere and tried to look at the work of others, but to no avail. I am still unable to pull, parse, and use the information from a selected grid screen item.

Doing things like this:


column = msg.GetData()
row = msg.GetIndex()

title = grid[column]
title = title[row]
title = title.Title
print "Title => "+title.toStr()

**AND**

title = grid[msg.GetData()][msg.GetIndex()].Title.toStr()
print "Title => "+title


all result in


Array operation attempted on variable not DIM'd. (runtime error &he7) in ...TZPco/pkg:/source/appMain.brs(91)
091: title = grid[msg.GetData()][msg.GetIndex()].Title.gettext()


and unfortunately there is absolutely no documentation in the Brightscript manual or online information about how to get information from a selected grid screen item.

So how in the world do you click on an item and be able to use the information from the item that was clicked on?
שלום חבר

Dean at the School of Truth: a part of Autodidact University.

"A programmer is just a tool which converts caffeine into code"
Temet nosce
Vi Veri Veniversum Vivus Vici
Si vis pacem, para bellum
0 Kudos