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

SOLVED - How do I control when menu item is selected?

Right now when a user opens the channel, the last item in the menu chain is selected. In our case it is our store. Knowing our particular audience many will be offended by that and assume we did that on purpose and are shoving our products down their throat.

Wanting to avoid this impending complaint, i would like to make it so the first item in our main menu is selected when they first open the channel.

How do I do that? Is there some code I put into the XML?
0 Kudos
8 REPLIES 8
tacticalcity
Visitor

Re: Ho do I control when menu item is selected at opening?

Nobody has done this yet?
0 Kudos
EnTerr
Roku Guru

Re: Ho do I control when menu item is selected at opening?

Slow down, please. This is a forum/message board - not IRC/instant messaging.
After asking a question, give it say 3 workdays before wondering why no answers.
And in the case of RokuCo employees, make that a week or two. (No guarantee)

PS. also, do your own research - most of such questions (new bugs notwithstanding) have already been asked and answered in the past.
0 Kudos
RokuJoel
Binge Watcher

Re: Ho do I control when menu item is selected at opening?

Hi, it would be helpful to see your code - are you using roListScreen or displaying a menu in some other way? With an roListScreen you can call setFocusedListItem(0) to select the first item in the list.

- Joel
0 Kudos
tacticalcity
Visitor

Re: Ho do I control when menu item is selected at opening?

@eRR Terr
I get the assumption that I would have just posted without searching, but that is not the case with me. I search first. And I keep searching rather than just relying on one source for information. If the question has been asked before then I am using the wrong keywords to find the answer. For example, I found the developers blog had some tips on how to play an into video (my other open question). It's a bit complicated and over my head...but I'm gonna give it a go the first moment I have to cut my teeth into it.

As far as slowing my roll...felt like an eternity to me! 😉 It had been a couple days, and JT had me spoiled by solving my previous issues same day. It is not like I am snapping my fingers at you. I was just surprised 33 other developers had a chance to look at it, and all of them were like me and had no idea how to solve it. Figured this would have come up before.

BACK TO BUISINESS...

@ RokuJoel
I am using the VideoPlayer example/template from the SDK. To my knowledge I have not changed that part of the code. The only "code" related changes I made where to change the color of some text and to remove the ratings stars for the video. JT helped me figure both those things out. I can look up more information when I get hope tonight. But I started this Jan 5th, and am using the version of the SDK that was available for download then. I doubt it has changed since then.

If that doesn't answer your question, no worries. Tonight when I get home I would look inside my .zip folder and find what is being used and post it here.

I am a big time NOOB. Used to do some web development, but got out of the game when XML took off. And BrightScript is pretty foreign to me. So slow walk me through this please. Thanks much. Appreciate the help and patience.
0 Kudos
tacticalcity
Visitor

Re: Ho do I control when menu item is selected at opening?

OK, so here are the files inside my SOURCE folder for the Video Player example from the SDK that I am using.

Which file do you need me to get you the code for? I peeked around inside of them and did not see roListScreen anywhere. But I may have missed it.

0 Kudos
tacticalcity
Visitor

Re: How do I control when menu item is selected at opening?

This is the screen I am trying to change.



It is automatically selecting the last item in the list of categories. But I think my using the word "list" is confusing people. Because I think this page might be controlled via the appPosterScreen.brs.
0 Kudos
tacticalcity
Visitor

Re: How do I control when menu item is selected at opening?

I tried making the suggested change above to the following code, but it had no effect. It did not break anything, but it didn't change the behavior on any of the screens either.

'******************************************************
'** Display the home screen and wait for events from
'** the screen. The screen will show retreiving while
'** we fetch and parse the feeds for the game posters
'******************************************************
Function showPosterScreen(screen As Object, category As Object) As Integer

if validateParam(screen, "roPosterScreen", "showPosterScreen") = false return -1
if validateParam(category, "roAssociativeArray", "showPosterScreen") = false return -1

m.curCategory = 0
m.curShow = 0
temp=getcategorylist(category)


if temp.count() > 1 then
screen.SetListNames(temp)
?temp.count();" categories"
else
?"only ";temp.count();" category"
end if
screen.SetContentList(getShowsForCategoryItem(category, m.curCategory))
screen.Show()

while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roPosterScreenEvent" then
print "showPosterScreen | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
if msg.isListFocused() then
m.curCategory = msg.GetIndex()
m.curShow = 0
screen.setcontentlist([])
screen.SetFocusedListItem(0)
screen.showmessage("Retrieving")
screen.SetContentList(getShowsForCategoryItem(category, m.curCategory))
screen.clearmessage()
print "list focused | current category = "; m.curCategory
else if msg.isListItemSelected() then
m.curShow = msg.GetIndex()
print "list item selected | current show = "; m.curShow
m.curShow = displayShowDetailScreen(category, m.curShow)
screen.SetFocusedListItem(m.curShow)
print "list item updated | new show = "; m.curShow
else if msg.isScreenClosed() then
return -1
end if
end If
end while


End Function
0 Kudos
tacticalcity
Visitor

Re: How do I control when menu item is selected at opening?

OK, so i was looking in the wrong .brs file. Needed to be looking in the appHomeScreen.brs which makes sense given the name.

I needed to make this change...


Find this block of code (this is the edited version.



'******************************************************
'** Display the home screen and wait for events from
'** the screen. The screen will show retreiving while
'** we fetch and parse the feeds for the game posters
'******************************************************
Function showHomeScreen(screen) As Integer

if validateParam(screen, "roPosterScreen", "showHomeScreen") = false return -1

initCategoryList()
screen.SetContentList(m.Categories.Kids)
screen.SetFocusedListItem(0)
screen.Show()

while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roPosterScreenEvent" then
print "showHomeScreen | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
if msg.isListFocused() then
print "list focused | index = "; msg.GetIndex(); " | category = "; m.curCategory
else if msg.isListItemSelected() then
print "list item selected | index = "; msg.GetIndex()
kid = m.Categories.Kids[msg.GetIndex()]
if kid.type = "special_category" then
displaySpecialCategoryScreen()
else
displayCategoryPosterScreen(kid)
end if
else if msg.isScreenClosed() then
return -1
end if
end If
end while

return 0

End Function


And make sure this value in side the () was 0

screen.SetFocusedListItem(0)


Just like I was told do above...I just didn't know which file to do this in.

Why am I spelling all this out? So the next guy using the VideoPlayer example who wants to make the same change will know what to do.
0 Kudos