0

Example of roTextWidget programming in custom .brs



I would like some examples of how to display content using zones in a custom BrightScipt file. Specifically, how does one display TextWidgets from scratch? As a general rule, is it better to use roTextField() or roTextWidget() for system messages and UI feedback? For example: if I have a script that is processing content or saving settings and I'd like to display legible, nice looking information to a user, what are the reasons to use one over the other? Thanks

5 comments

  • 0
    Avatar
    RokuLyndon


    Give me a specific example of what you want to see? There are sample scripts in the object reference guide. You want to use a rotextwidget for your text zones.

    There's a show and hide function you can use with text widgets, and a push command to add strings to your text widget.
  • 0
    Avatar
    amnhrce


    "RokuLyndon" wrote:

    Give me a specific example of what you want to see? There are sample scripts in the object reference guide. You want to use a rotextwidget for your text zones.

    There's a show and hide function you can use with text widgets, and a push command to add strings to your text widget.

    Hi Lyndon,
    I slightly altered a code example from the BrightSign Object Reference for BrightSign software version 3.3.78 on pages 67 and 68 (under roBrightPackage()) but I was not able to get this to work. I put this snippet exactly as-is into a file named showtxt.brs and ran it manually from the BrightSign Shell as:

    BrightSign> script usb1:/showtxt.brs
    REM Print Me

    Sub Main()
        r = CreateObject("roRectangle", 20, 668, 1240, 80)
        textWidget = CreateObject("roTextWidget",r,1,2,1)
        r = CreateObject("roRectangle", 20, 20, 1200, 40)
        textWidget.SetSafeTextRegion(r)
        textWidget.SetForegroundColor(&hff303030)
        textWidget.SetBackgroundColor(&hffffffff)
        textWidget.PushString("Hello World!")
        textWidget.Show()
    End Sub

    The script appeared to run without errors but I did not see any text on the video output.
  • 0
    Avatar
    RokuLyndon


    It might be because the script exited to the shell at the end of running. Inside the main function, at the very end, add a sleep statement to keep the script active. Sleep is in terms of milliseconds. So, to keep it running for 30 seconds, add:

    sleep(30000)
  • 0
    Avatar
    amnhrce


    "RokuLyndon" wrote:

    It might be because the script exited to the shell at the end of running. Inside the main function, at the very end, add a sleep statement to keep the script active. Sleep is in terms of milliseconds. So, to keep it running for 30 seconds, add:

    sleep(30000)

    That did the trick. Thanks Lyndon!

    Working code:
    REM Print Me

    Sub Main()
       r = CreateObject("roRectangle", 20, 668, 1240, 80)
       textWidget = CreateObject("roTextWidget",r,1,2,1)
       r = CreateObject("roRectangle", 20, 20, 1200, 40)
       textWidget.SetSafeTextRegion(r)
       textWidget.SetForegroundColor(&hff303030)
       textWidget.SetBackgroundColor(&hffffffff)
       textWidget.PushString("Hello World!")
       textWidget.Show()
       ' Give the BrightSign time to process the command before exiting
       sleep(30000)
    End Sub

  • 0
    Avatar
    RokuLyndon


    The sleep is only required because you don't have a loop of any kind of the script.
Please sign in to leave a comment.