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: 
jbrave
Channel Surfer

problems with roMessageDialog

What could make a dialog box in the Main loop not show up? To make a long story short, I set up the dialog box to display with animation in a bunch of places, but in one "if/then" section, it just doesn't open. So I removed from everywhere else, and it still didn't work in this one else if then statement. So I stuck in another dialog.setmessageport(port) in front of the dialog.show() line and it worked - the first time through, but after that it doesn't work.

The whole point of sticking this in was there is a weird thing going on with this particular section where if I click "previous" or "next" and then quickly go to another section while it loads and do the same thing, one section (category filter posterlist) will replace the other one, even though the index is different. Very odd. So I wanted to quick-fix it by preventing anyone from changing category-filter sections while it loaded. That is when I encountered the weird dialog.show() issue. I'm sure the two are related, but I'm not sure how.



'm.li is global msg.GetIndex() var updated whenever msg.getmessage=isListFocused() orIslistSelected()
'itemindex is updated whenever IsListItemSelected()
else if m.li = 3 and mainposter[m.li].poster[itemindex].action="previous"
dialog.setmessageport(port)
dialog.show()
?"dialog should be showing"
m.co[3]=m.co[3]-m.limit 'page backwards
? "new offset"
?m.co[3]
?m.li
mainposter[3]=ReloadTracks(mainposter[3],PrepLatestTracks(m.co[3],m.limit))
?"close dialog"

dialog.close()

?"dialog should be closed"
else if m.li = 3 and mainposter[m.li].poster[itemindex].action="next"
dialog.setmessageport(port)
dialog.show()
?"Latest tracks section and a Page Forward item has been selected"
m.co[m.li]=m.co[m.li]+m.limit 'page forwards
? "new offset"
?m.co[m.li]
?m.li
mainposter[3]=ReloadTracks(mainposter[3],PrepLatestTracks(m.co[3],m.limit))
dialog.close()
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
5 REPLIES 5
renojim
Community Streaming Expert

Re: problems with roMessageDialog

You're opening it and then pretty much immediately closing it. If you just want to flash something for a brief period of time, put a sleep(2000) after the show. If you want it to stay up until you press a button, use something like this routine to pop up a message:

Sub ShowOkDialog(title as String, text as String)
port = CreateObject("roMessagePort")
dialog = CreateObject("roMessageDialog")
dialog.SetMessagePort(port)

dialog.SetTitle(title)
dialog.SetText(text)
dialog.AddButton(1, "Ok")
dialog.Show()

dlgMsg = wait(0, dialog.GetMessagePort())
End Sub

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
mike_ryan
Visitor

Re: problems with roMessageDialog

If you look at the generalDlgs.brs file in the videoplayer sample app it has a bunch of nice little utility subs for showing various message dialogs.

We usually package this file with a few of the other util files in our apps, no need to reinvent the wheel.
0 Kudos
jbrave
Channel Surfer

Re: problems with roMessageDialog

Actually there is about 15-20 seconds that it is open, that is how long it takes to download and process all that data.
It needs to open before the function call and close afterwards
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
kbenson
Visitor

Re: problems with roMessageDialog

"jbrave" wrote:
Actually there is about 15-20 seconds that it is open, that is how long it takes to download and process all that data.
It needs to open before the function call and close afterwards


I'm not sure about this case, but many calls to methods on components are non-blocking, so it won't actually wait until it's finished before continuing with the code. If there's an event generated on completion, you can check for that, but that's not always the case (such as with roImageCanvas).
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
jbrave
Channel Surfer

Re: problems with roMessageDialog

There is an isScreenClosed() message. I don't know if that indicates that it is non-blocking. I also wonder how calling subroutines or functions affects a screen display when the screen only exists in the main() context. I suppose I could define a global port and dialog box and see how that works. m.port, m.dialog ...
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
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.