content: sub InitScreenStack()
    m.screenStack = []
  end sub
  
  sub ShowScreen(node as object)
    prev = m.screenStack.Peek() ' take current screen from screen stack but don't delete it
  
    if prev <> invalid
      prev.visible = false 'hide current screen if it exists
    end if
  
    ' show new screen
    m.top.AppendChild(node)
    node.visible = true
    node.SetFocus(true)
    m.screenStack.Push(node)
  end sub
  
  sub CloseScreen(node as object)
    if node = invalid or (m.screenStack.Peek() <> invalid and m.screenStack.Peek().isSameNode(node))
      last = m.screenStack.Pop() ' remove screen from screenStack
      last.visible = false ' hide screen
      m.top.RemoveChild(node) ' remove screen from scene
  
      ' take previous screen and make it visible
      prev = m.screenStack.Peek()
      if prev <> invalid
        prev.visible = true
        prev.SetFocus(true)
      end if
    end if
  end sub