anchor.diff:  
   { MyScene }
   Constructor MyScene.Create;
  -Var
  -  Btn:UIButton;
  -  W:Widget;
  -  I:Integer;
  -  MyTex:Texture;
   Begin
  -  // Get background texture
  -  MyTex := TextureManager.Instance.GetTexture('background');
  +  UITemplates.AddTemplate(UIWindowTemplate.Create('wnd_template', TextureManager.Instance.GetTexture('ui_window'), 45, 28, 147, 98));
  +  UITemplates.AddTemplate(UIButtonTemplate.Create('btn_template', TextureManager.Instance.GetTexture('ui_button2'), 25, 10, 220, 37));
   
  -  // Create a UI background
  -  If Assigned(MyTex) Then
  -  Begin
  -    Background := UISprite.Create('mybg', MyUI, 0, 0, 1);
  +  MyWnd := UIInstancedWidget.Create('mywnd', MyUI, 0, 0, 10, UIPixels(643), UIPixels(231), 'wnd_template');
  +//  MyWnd.Draggable := True;
  +  MyWnd.Align := waCenter;
   
  -    Background.SetTexture(MyTex);
  -    Background.Width := UIScreenWidthPercent(100);
  -    Background.Height := UIScreenHeightPercent(100);
  +  MyBtn := UIInstancedWidget.Create('mybtn', MyWnd, 0, 0, 1, UIPixels(250), UIPixels(50), 'btn_template');
  +  MyBtn.Align := waCenter;
  +  MyBtn.SetEventHandler(widgetEvent_MouseDown, OnMyButtonClick); // Assign a onClick event handler
  +End;
   
  -    Background.U2 := 2;
  -    Background.V2 := 2;
  -  End;
  +Procedure MyScene.Release;
  +Begin
  +End;
   
  -  MyWnd := UIWindow.Create('mywnd', MyUI, 0, 0, 10, UIPixels(500), UIPixels(300), 'window');
  -  MyWnd.Align := waCenter;
  -  MyWnd.Draggable := True;
  -
  -  Tabs := UITabList.Create('tabs1', MyWnd, 10, 0, 1, UIPixels(100), UIPixels(30), 'tabs');
  -  Tabs.Font := SmallFnt;
  -  //Tabs.Align := waTopRight;
  -  MyWnd.TabControl := Tabs;
  -
  -  For I:=0 To 2 Do
  -    Tabs.AddTab('Tab'+IntToString(I), I);
  -
  -  For I:=0 To 2 Do
  -    Btn := UIButton.Create('btn1', MyWnd, 20 + I * 120, 40, 10, UIPixels(100), UIPixels(50), 'Btn'+IntToString(I), 'button', I);
  -
  -  MyScroll := UIScrollBar.Create('myscroll', MyWnd, 10, 20, 5, UIPixels(20), UIPixels(260), UIPixels(10), UIPixels(26), 'vscroll');
  -  MyScroll.Align := waTopRight;
  -  MyScroll.TabIndex := 0;
  -  MyScroll.Max := 600;
  -
  -  // Not all widgets need a parent
  -  // If you pass Nil as parent, the screen will be considered their parent
  -  W := UILabel.Create('mylabel', MyWnd, 20, 20, 10, 'This is an aligned text label.');
  -  W.Align := waBottomRight;
  -  W.TabIndex := 1;
  -
  -  W := UISprite.Create('test', MyWnd, 150, 50, 1, 'cobble', 0);
  -  W.Scroll := MyScroll;
  -
  -  W := UISprite.Create('test', MyWnd, 150, 300, 1, 'fur_diffuse', 0);
  -  W.Scroll := MyScroll;
  -
  -  W := UISprite.Create('test', MyWnd, 150, 550, 1, 'marble_diffuse', 0);
  -  W.Scroll := MyScroll;
  -
  -  W := UIIcon.Create('test', MyWnd, 50, 50, 1, UIPixels(100), UIPixels(100), 'ghosticon', 2);
  +// GUI event handlers
  +// All event handlers must be procedures that receive a Widget as argument
  +// The Widget argument provides the widget that called this event handler
  +Procedure MyScene.OnMyButtonClick(Src:UIWidget);
  +Begin
  +  IntToString(2);
  + // MyUI.MessageBox('You clicked the button!');
   End;
   
   {$IFDEF IPHONE}
  
positive.code: 
  Procedure Demo.OnMouseMove(X, Y: Integer);
  Begin
    MyUI.OnMouseMove(X, Y);
  End;
  
  
negative.code: {$I terra.inc}
  {$IFDEF MOBILE}Library{$ELSE}Program{$ENDIF} MaterialDemo;
  
  uses
    MemCheck,
    TERRA_Object,
    TERRA_MemoryManager,
    TERRA_Application,
    TERRA_Utils,
    TERRA_ResourceManager,
    TERRA_GraphicsManager,
    TERRA_OS,
    TERRA_Vector2D,
    TERRA_Font,
    TERRA_Texture,
    TERRA_FileManager,
    TERRA_InputManager,
    TERRA_Collections,
    TERRA_CollectionObjects,
    TERRA_TTF,
    TERRA_PNG,
    TERRA_Scene,
    TERRA_Color,
    TERRA_String,
    TERRA_Matrix4x4,
    TERRA_UIView,
    TERRA_UIWidget,
    TERRA_UITemplates,
    TERRA_UIImage,
    TERRA_UITiledRect,
    TERRA_UIDimension;
  
  Type
    Demo = Class(Application)
      Protected
        _Scene:TERRAScene;
  
      Public
  			Procedure OnCreate; Override;
  			Procedure OnDestroy; Override;
  			Procedure OnMouseDown(X,Y:Integer; Button:Word); Override;
  			Procedure OnMouseUp(X,Y:Integer; Button:Word); Override;
  			Procedure OnMouseMove(X,Y:Integer); Override;
  
  			Procedure OnIdle; Override;
    End;
  
    MyScene = Class(TERRAScene)
        Constructor Create;
        Procedure Release; Override;
  
        Procedure OnMyButtonClick(Src:UIWidget);
    End;
  
  Var
    Fnt:TERRAFont;
    MyUI:UIView;
    MyWnd, MyBtn:UIWidget;
  
  { Game }
  Procedure Demo.OnCreate;
  Begin
    FileManager.Instance.AddPath('Assets');
  
    // Load a font
    Fnt := FontManager.Instance.GetFont('droid');
  
    // Create a new UI
    MyUI := UIView.Create;
  
    // Register the font with the UI
    MyUI.DefaultFont := Fnt;
  
    // Create a empty scene
    _Scene := MyScene.Create;
    GraphicsManager.Instance.Scene := _Scene;
  
    GraphicsManager.Instance.DeviceViewport.BackgroundColor := ColorBlue;
  End;
  
  Procedure Demo.OnDestroy;
  Begin
    ReleaseObject(_Scene);
  End;
  
  Procedure Demo.OnIdle;
  Begin
    If InputManager.Instance.Keys.WasPressed(keyEscape) Then
      Application.Instance.Terminate;
  End;
  
  Procedure Demo.OnMouseDown(X, Y: Integer; Button: Word);
  