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: 
360tv
Streaming Star

ShowMessageDialog

so if I plop this code from the component reference into my appHomeScreen.brs...

Function ShowMessageDialog() As Void
port = CreateObject("roMessagePort")
dialog = CreateObject("roMessageDialog")
dialog.SetMessagePort(port)
dialog.SetTitle("[Message dialog title]")
dialog.SetText("[Message dialog text............]")
dialog.AddButton(1, "[button text]")
dialog.Show()
while true
dlgMsg = wait(0, dialog.GetMessagePort())
if type(dlgMsg) = "roMessageDialogEvent"
if msg.isScreenClosed()
exit while
end if
end if
end while
End Function


it freezes after it shows up. Button 1 doesn't do anything and I have to exit out of the app entirely. What's going on with that?

My goal is to create sort of a "Message Of The Day" kinda thing. But my first step is to get a simple dialog box to work. Then I'll address how to feed it the information I want (probably thru a separate xml feed).
0 Kudos
3 REPLIES 3
TheEndless
Channel Surfer

Re: ShowMessageDialog

There's no handler in there for the button selection. Modify it to handle the button selection.

Function ShowMessageDialog() As Void
port = CreateObject("roMessagePort")
dialog = CreateObject("roMessageDialog")
dialog.SetMessagePort(port)
dialog.SetTitle("[Message dialog title]")
dialog.SetText("[Message dialog text............]")
dialog.AddButton(1, "[button text]")
dialog.Show()
while true
dlgMsg = wait(0, dialog.GetMessagePort())
if type(dlgMsg) = "roMessageDialogEvent" then
if msg.isScreenClosed() then
exit while
else if msg.isButtonPressed() then
' This assumes you only have one button and you want it
' to close the dialog when selected, otherwise check
' msg.GetIndex() and respond appropriately
dialog.Close()
end if
end if
end while
End Function
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
360tv
Streaming Star

Re: ShowMessageDialog

How?

As I'm reading the code, what you've typed in should make the dialog box close when you click the button (right?). But it dosen't.
0 Kudos
TheEndless
Channel Surfer

Re: ShowMessageDialog

Oops. I just copied and modified the code you posted earlier. The problem is that that code assigns the variable "dlgMsg" but checks "msg". Try this instead.

Function ShowMessageDialog() As Void
port = CreateObject("roMessagePort")
dialog = CreateObject("roMessageDialog")
dialog.SetMessagePort(port)
dialog.SetTitle("[Message dialog title]")
dialog.SetText("[Message dialog text............]")
dialog.AddButton(1, "[button text]")
dialog.Show()
while true
msg = wait(0, dialog.GetMessagePort())
if type(msg) = "roMessageDialogEvent" then
if msg.isScreenClosed() then
exit while
else if msg.isButtonPressed() then
' This assumes you only have one button and you want it
' to close the dialog when selected, otherwise check
' msg.GetIndex() and respond appropriately
dialog.Close()
end if
end if
end while
End Function
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
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.