By default, an empty or undefined layer is fully transparent.
When creating an roimagecanvas - the first screen will not have anything below it, so it works fine without specifically declaring the background to be opaque.
On subsequent screens, they are acting as overlays with transparent backgrounds, so you'll need to set the base transparency or the prior screens will show through.
screen.SetLayer(0,{Color:"#FF000000",CompositionMode:"Source"}) 'Black opaque background
Try out the following code -- this isn't optimized but it's easy to troubleshoot to see what's going on to do it as longhand.
Sub Main()
canvas=CreateObject("roImageCanvas") 'create facade screen
'note - this facade screen is fully transparent with nothing in it, existing simply so the app doesn't prematurely exit
canvas.Show() 'display the facade
ShowScreen1() 'Biiiird....GO!
End Sub
Sub ShowScreen1()
port=CreateObject("roMessagePort") 'create a new local message port
screen=CreateObject("roImageCanvas") 'canvas for local screen
screen.SetMessagePort(port) 'set local port to local screen
canvasItems=[
{
Text:"1 - press down for next screen, up or back to quit"
TextAttrs:{Color:"#FFCCCCCC", Font:"Medium",
HAlign:"HCenter", VAlign:"VCenter",
Direction:"LeftToRight"}
TargetRect:{x:390,y:357,w:500,h:60}
}
]
screen.SetLayer(0,{Color:"#FF000000",CompositionMode:"Source"}) 'Black opaque background
screen.SetLayer(1,canvasItems)
screen.show() 'display the screen
While TRUE
msg=Wait(0,port)
If type(msg)="roImageCanvasEvent"
If msg.isScreenClosed()
Exit While
Else If msg.isRemoteKeyPressed()
Print msg.GetMessage()
ButtonNum=msg.GetIndex()
Print"Button Pressed msg: ";ButtonNum
If ButtonNum=2 Or ButtonNum=0 Exit While 'UP PRESSED OR BACK PRESSED
If ButtonNum=3 ShowScreen2() 'DOWN PRESSED
End If
End If
End While
End Sub
Sub ShowScreen2()
port=CreateObject("roMessagePort") 'create a new local message port
screen=CreateObject("roImageCanvas") 'canvas for local screen
screen.SetMessagePort(port) 'set local port to local screen
canvasItems=[
{
Text:"2 - press down for next screen, up or back for previous screen"
TextAttrs:{Color:"#FFCCCCCC", Font:"Medium",
HAlign:"HCenter", VAlign:"VCenter",
Direction:"LeftToRight"}
TargetRect:{x:390,y:357,w:500,h:60}
}
]
screen.SetLayer(0,{Color:"#FF000000",CompositionMode:"Source"}) 'Black opaque background
screen.SetLayer(1,canvasItems)
screen.show() 'display the screen
While TRUE
msg=Wait(0,port)
If type(msg)="roImageCanvasEvent"
If msg.isScreenClosed()
Exit While
Else If msg.isRemoteKeyPressed()
Print msg.GetMessage()
ButtonNum=msg.GetIndex()
Print"Button Pressed msg: ";ButtonNum
If ButtonNum=2 Or ButtonNum=0 Exit While 'UP PRESSED OR BACK PRESSED
If ButtonNum=3 ShowScreen3() 'DOWN PRESSED
End If
End If
End While
End Sub
Sub ShowScreen3()
port=CreateObject("roMessagePort") 'create a new local message port
screen=CreateObject("roImageCanvas") 'canvas for local screen
screen.SetMessagePort(port) 'set local port to local screen
canvasItems=[
{
Text:"3 - press up or back for previous screen"
TextAttrs:{Color:"#FFCCCCCC", Font:"Medium",
HAlign:"HCenter", VAlign:"VCenter",
Direction:"LeftToRight"}
TargetRect:{x:390,y:357,w:500,h:60}
}
]
screen.SetLayer(0,{Color:"#FF000000",CompositionMode:"Source"}) 'Black opaque background
screen.SetLayer(1,canvasItems)
screen.show() 'display the screen
While TRUE
msg=Wait(0,port)
If type(msg)="roImageCanvasEvent"
If msg.isScreenClosed()
Exit While
Else If msg.isRemoteKeyPressed()
Print msg.GetMessage()
ButtonNum=msg.GetIndex()
Print"Button Pressed msg: ";ButtonNum
If ButtonNum=2 Or ButtonNum=0 Exit While 'UP PRESSED OR BACK PRESSED
End If
End If
End While
End Sub