Trader5050
Newbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2015
08:14 PM
**Solved** Dialog not displaying
I have the following code in main() just after show()
and then...
... but the dialog is never displayed. What gives?
If targetAddress = "" then
showOKDialog("Notice","Due to Roku restrictions, blah blah blah blah........")
Else
' debug testing... why is this not displaying either
showOKDialog("Test",targetAddress)
End if
and then...
Sub showOKDialog(title = "NOTE" as String,message = "Press OK to continue" as String)
port = CreateObject("roMessagePort")
dialog = CreateObject("roMessageDialog")
dialog.SetMessagePort(port)
dialog.SetTitle(ttl)
dialog.SetText(message)
dialog.AddButton(1, "OK")
dialog.EnableBackButton(true)
dialog.Show()
While True
dlgMsg = wait(0, dialog.GetMessagePort())
If type(dlgMsg) = "roMessageDialogEvent"
if dlgMsg.isButtonPressed()
if dlgMsg.GetIndex() = 1
exit while
end if
else if dlgMsg.isScreenClosed()
exit while
end if
end if
end while
End Sub
... but the dialog is never displayed. What gives?
3 REPLIES 3
belltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2015
10:04 PM
Re: Dialog not displaying
What code do you have in main()?
Trader5050
Newbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2015
08:12 AM
Re: Dialog not displaying
Sub Main()
'initialize theme attributes like titles, logos and overhang color
initTheme()
'display a fake screen while the real one initializes. this screen
'has to live for the duration of the whole app to prevent flashing
'back to the roku home screen.
screenFacade = CreateObject("roParagraphScreen")
screenFacade.addParagraph("Please wait...")
screenFacade.show()
' =========================
' GET SETTINGS FROM REGISTRY
' =========================
targetAddress = RegRead("ip")
targetPort = RegRead("port")
targetUsername = RegRead("username")
targetPassword = RegRead("password")
If targetAddress = "" then
showOKDialog("Notice","Due to Roku restrictions, only blah blah blah....") ' to fix later
Else
' debug testing... why is this not displaying either
showOKDialog("Test",targetAddress)
End if
That is literally the only thing leading up to the sub for the dialog. The program displays fine ("Please wait...") but nothing else ever happens.
The RegRead and RegWrite are some simple ones that I found on the forum here that a lot of folks seem to be using.
Trader5050
Newbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2015
08:43 AM
Re: Dialog not displaying
Nevermind, fixed!
I had to change it to a function, for whatever reason. I did make a few other minor modifications so I can't say for sure that's what did it, but here's the code:
I had to change it to a function, for whatever reason. I did make a few other minor modifications so I can't say for sure that's what did it, but here's the code:
Function showOKDialog(title = "NOTE" as String,message = "Press OK to continue" as String,buttonText = "OK" as String) as Void
port = CreateObject("roMessagePort")
dialog = CreateObject("roMessageDialog")
dialog.SetMessagePort(port)
dialog.SetTitle(title)
dialog.SetText(message)
dialog.AddButton(1, buttonText)
dialog.EnableBackButton(true)
dialog.Show()
While True
dlgMsg = wait(0, dialog.GetMessagePort())
If type(dlgMsg) = "roMessageDialogEvent"
If dlgMsg.isButtonPressed()
If dlgMsg.GetIndex() = 1
exit while
End If
Else If dlgMsg.isScreenClosed()
exit while
End If
End If
End While
End Function