Forum Discussion

jbrave's avatar
jbrave
Channel Surfer
15 years ago

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()

5 Replies

  • renojim's avatar
    renojim
    Community Streaming Expert
    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
  • 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.
  • jbrave's avatar
    jbrave
    Channel Surfer
    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
  • "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).
  • jbrave's avatar
    jbrave
    Channel Surfer
    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 ...