//--- OBJECT WRITE BEGIN ---
new GuiControl(ConsoleDlg) {
   profile = "GuiDefaultProfile";
   
   new GuiWindowCtrl()
   {
      profile = "GuiWindowProfile";
      position = "0 0";
      extent = "640 370";
      text = "Console";
      
      new GuiScrollCtrl()
      {
         profile = "GuiButtonProfile";
         position = "0 0";
         extent = "640 350";
         hScrollBar = "alwaysOn";
         vScrollBar = "alwaysOn";
         horizSizing = "width";
         vertSizing = "height";
      
         new GuiScrollContentCtrl("testScrollContentCtrl")
         {
            profile = "GuiButtonProfile";
            
            new GuiConsole("testArrayCtrl")
            {
               profile = "GuiConsoleProfile";
               position = "0 0";
            };
         };
      };
      
      new GuiConsoleEditCtrl("ConsoleEntry")
      {
         profile = "GuiTextEditProfile";
         position = "0 350";
         extent = "640 20";
         historySize = 20;
         altCommand = "ConsoleEntry::eval();";
         horizSizing = "width";
         vertSizing = "top";
      };
   };
};
//--- OBJECT WRITE END ---

$ConsoleActive = false;

function ConsoleEntry::eval()
{
   %text = ConsoleEntry.getValue();
   echo("==>" @ %text);
   eval(%text);
   ConsoleEntry.setValue("");
}

function ToggleConsole(%make)
{
   if (%make)
   {
      if ($ConsoleActive)
      {
         Canvas.popDialog(ConsoleDlg);
         $ConsoleActive = false;
         if ( $enableDirectInput )
            activateKeyboard();
      }
      else
      {
         Canvas.pushDialog(ConsoleDlg, 99);
         $ConsoleActive = true;
         deactivateKeyboard();
      }
   }
}


