I should add that I want to launch a separate instance of roScreen because I'm considering building a screen library that allows me to build apps that are more like Hulu+ than the standard ro components. Creating new instances simplifies the object model considerably.
This code is just a prototype to help me test the possibilities. So my red screen object would look something like this:
Function CreateRedScreen() as Object
obj = CreateScreenCore()
obj.draw = Function()
m.screen.Clear(&hFFFF00FF)
m.screen.SwapBuffers()
End Function
obj.display = function()
m.Draw()
msg = wait(1, m.port)
if type(msg) = "roUniversalControlEvent" then
if msg.GetInt() = 5
print "Red screen value is ", m.value
m.value = m.value + 1
endif
endif
return CreateScreenEvent(m.screen, msg)
end function
obj.screen.SetMessagePort(obj.port)
return obj
End Function
And you can see then, how that can be extended. The caller of "red screen" would be something like:
Function showNewRedScreen()
redScreen = CreateRedScreen()
while true
event = redScreen.display()
if type(event.msg) = "roUniversalControlEvent" then
if event.msg.GetInt() = 6
ShowGreenScreen()
endif
endif
end while
End Function
Now, RedScreen can handle it's own events, and pass back both events of it's own as well as events that it otherwise ignores.