Forum Discussion

btpoole's avatar
btpoole
Channel Surfer
9 years ago

Close Channel

Trying to close a channel from a menu. The user clicks ok on a button (on screen) to exit the channel. Not really getting it, can somebody point me down the correct path. I have a function in the main.brs

function home()
?"IN HOME"
screen = CreateObject("roSGScreen")
port = CreateObject("roMessagePort")
screen.setMessagePort(port)
scene =screen.CreateScene("HomeScene")
screen.show()
[size=85][font=Helvetica Neue, Helvetica, Arial, sans-serif]    while (true)[/font][/size]
     msg = wait(0, port)
      msgType = type(msg)
      ?msgType
       if msgType = "roSGScreenEvent"
          if msg.isScreenClosed()
            EXIT WHILE
[size=85][font=Helvetica Neue, Helvetica, Arial, sans-serif]      end if[/font][/size]

    end if
end while
end function

So later on in the channel if the user wants to exit instead of hitting the home button a menu option on the screen could be picked. In order to do this I have created a task to handle the button selection but not really getting anything to work.

<component name = "exitapp" extends = "Task" >
  <interface>
    <field id = "Content" type = "node" />
 </interface>
 <script type="text/brightscript" uri="pkg:/source/main.brs" />

  <script type = "text/brightscript" >
    <![CDATA[

sub init()
PRINT "IN EXIT TASK"
m.top.functionName = "exitout"
end sub

function exitout()
screen.close()
end function

]]>
  </script>

</component>

19 Replies