Your Digital Media Has Never Looked So Good

 
lisakb140
Topic Author
Posts: 28
Joined: Tue Aug 14, 2018 8:18 am

Label Node Created in main.brs not rendering

Thu Oct 11, 2018 7:59 am

I am creating a label in my main.brs with CreateObject, which I thought would be fairly simple. However, it is not rendering, and I have no idea why. 

This happens within a function where I create a VideoNode via CreateObject, and that seems to show up fine.

My code is:

label = CreateObject("roSGNode", "Label")
  label.text = "EPISODES AVAILABLE"
  label.translation="[50, 50]"
  label.numlines="1"
  label.color="0xFFFFFF"
  label.id = "episodeslabel"


If I print label, I get this, which looks correct to me, but it just doesn't appear anywhere on the screen (as if visibility were false)! What am I missing?!


<Component: roSGNode:Label> =
{
    color: -1
    displayPartialLines: false
    ellipsisText: ""
    ellipsizeOnBoundary: false
    font: <Component: roSGNode:Font>
    height: 0
    horizAlign: "left"
    isTextEllipsized: false
    lineSpacing: 8
    maxLines: 0
    numLines: 1
    text: "EPISODES AVAILABLE"
    truncateOnDelimiter: ""
    vertAlign: "top"
    width: 0
    wordBreakChars: ""
    wrap: false
    childRenderOrder: "last"
    clippingRect: <Component: roAssociativeArray>
    enableRenderTracking: false
    inheritParentOpacity: true
    inheritParentTransform: true
    muteAudioGuide: false
    opacity: 1
    renderPass: 0
    renderTracking: "disabled"
    rotation: 0
    scale: <Component: roArray>
    scaleRotateCenter: <Component: roArray>
    translation: <Component: roArray>
    visible: true
    change: <Component: roAssociativeArray>
    focusable: false
    focusedChild: <Component: roInvalid>
    id: "episodeslabel"
}
 
User avatar
squirreltown
Posts: 836
Joined: Sun Apr 21, 2013 2:20 pm

Re: Label Node Created in main.brs not rendering

Thu Oct 11, 2018 10:27 am

I'd guess the color should be in this format  "0x000000".
color: -1
Kinetics Screensavers
 
lisakb140
Topic Author
Posts: 28
Joined: Tue Aug 14, 2018 8:18 am

Re: Label Node Created in main.brs not rendering

Thu Oct 11, 2018 11:24 am

Yeah, I'm not sure why that prints like that. In my brs I specify

label.color="0xFFFFFF"
 
User avatar
golewis
Posts: 3
Joined: Mon Jul 16, 2018 11:52 am

Re: Label Node Created in main.brs not rendering

Thu Oct 11, 2018 11:27 am

I think you need to add the label to the current view as a child object.  Use findNode() to get the node to which you wish to add the child.  Then use appendChild().  Reference here: Reference

Here's another way using createChild():

m.grid = m.top.findNode("gridRowList")
m.fade = m.grid.CreateChild("MaskGroup")
    m.fade.setFields({
            id: "fadeMaskGroup"
            maskuri: "pkg:/images/fade_3_sides.png"
            masksize: "[1280,720]"
            maskOffset: "[0,0]"
    })  
 
lisakb140
Topic Author
Posts: 28
Joined: Tue Aug 14, 2018 8:18 am

Re: Label Node Created in main.brs not rendering

Thu Oct 11, 2018 11:51 am

For some reason that throws a fatal error. I have:


row = [i]createObject[/i]("RoSGNode","VideoNode")
label = [i]CreateObject[/i]("roSGNode", "Label")
label.[b]text[/b] = "EPISODES AVAILABLE"
row.appendChild(label)


I'm not sure why that crashes things-- it doesn't seem that unusual to me..
               
 
lisakb140
Topic Author
Posts: 28
Joined: Tue Aug 14, 2018 8:18 am

Re: Label Node Created in main.brs not rendering

Thu Oct 11, 2018 11:52 am

For some reason that throws a fatal error. I have:


row = createObject("RoSGNode","VideoNode")
label = CreateObject("roSGNode", "Label")
label.text = "EPISODES AVAILABLE"
row.appendChild(label)


I'm not sure why that crashes things-- it doesn't seem that unusual to me..
               
 
lisakb140
Topic Author
Posts: 28
Joined: Tue Aug 14, 2018 8:18 am

Re: Label Node Created in main.brs not rendering

Thu Oct 11, 2018 12:54 pm

I tried reworking this a little, annd now I'm getting a Type mismatch error (appending a Label Node as a child to a VideoNode). Is that prohibited for some reason?
 
User avatar
golewis
Posts: 3
Joined: Mon Jul 16, 2018 11:52 am

Re: Label Node Created in main.brs not rendering

Thu Oct 11, 2018 1:04 pm

I think you meant to put "video" instead of "VideoNode"  (video)
 
User avatar
golewis
Posts: 3
Joined: Mon Jul 16, 2018 11:52 am

Re: Label Node Created in main.brs not rendering

Thu Oct 11, 2018 1:32 pm

Sorry for being vague.  I've just tried this in my videoview.brs and it worked for me. (I'm using SGDEX)
video = m.top.createChild("Video")
    video.id = "video"
    video.width = "1280"
    video.height = "720"
    video.translation = "[0,0]"
    video.enableUI = "false"
    video.disableScreenSaver = m.top.disableScreenSaver

    'Set m.video before setting theme as theme require m.video to be populated
    m.video = video

    if m.LastThemeAttributes <> Invalid then
        SGDEX_SetTheme(m.LastThemeAttributes)
    end if

    video.ObserveFieldScoped("position", "OnPositionChanged")
    video.ObserveFieldScoped("duration", "OnDurationChanged")
    video.ObserveFieldScoped("state", "OnVideoStateChanged")

label = CreateObject("roSGNode", "Label")
label.text = "EPISODES AVAILABLE"
video.appendChild(label)


If you're starting a channel from scratch I recommend the SGDEX Componentsand one of the SGDEX sample channels to get started. 
 
User avatar
georgejecook
Posts: 84
Joined: Thu Apr 05, 2018 2:17 pm

Re: Label Node Created in main.brs not rendering

Tue Oct 30, 2018 12:59 pm

you can't create a visual node before you initialize your scenegraph scene; unless you want all  h e l l  to break loose (crashing/hanging/cats loving dogs, end of the world scenarios).
George Cook
https://linkedin.com/in/georgejecook/
Roku developers slack group (http://tiny.cc/nrdf0y) : georgejecook

Contact me on roku developer slack group, or via pm to discuss consultancy/work opportunities/rooibos unit testing framework

Who is online

Users browsing this forum: No registered users and 7 guests