Changes after TouchedSignal changes
[platform/core/uifw/dali-demo.git] / examples / text-field / text-field-example.cpp
index 12fbae9..751380b 100644 (file)
@@ -67,14 +67,14 @@ public:
    */
   void Create( Application& application )
   {
-    Stage stage = Stage::GetCurrent();
+    Window window = application.GetWindow();
 
-    stage.SetBackgroundColor( Vector4( 0.04f, 0.345f, 0.392f, 1.0f ) );
-    stage.KeyEventSignal().Connect(this, &TextFieldExample::OnKeyEvent);
+    window.SetBackgroundColor( Vector4( 0.04f, 0.345f, 0.392f, 1.0f ) );
+    window.KeyEventSignal().Connect(this, &TextFieldExample::OnKeyEvent);
 
     mButton = CreateFolderButton();
     mButton.ClickedSignal().Connect( this, &TextFieldExample::OnButtonClicked );
-    stage.Add( mButton );
+    window.Add( mButton );
   }
 
   PushButton CreateFolderButton()
@@ -88,24 +88,24 @@ public:
 
   bool OnButtonClicked( Toolkit::Button button )
   {
-    Stage stage = Stage::GetCurrent();
-    Vector2 stageSize = stage.GetSize();
+    Window window = mApplication.GetWindow();
+    Vector2 windowSize = window.GetSize();
 
     // Remove previously hidden pop-up
     UnparentAndReset(mPopup);
 
     // Launch a pop-up containing TextField
-    mField = CreateTextField( stageSize, mButtonLabel );
+    mField = CreateTextField( windowSize, mButtonLabel );
     mPopup = CreatePopup();
     mPopup.Add( mField );
     mPopup.OutsideTouchedSignal().Connect( this, &TextFieldExample::OnPopupOutsideTouched );
-    stage.Add( mPopup );
+    window.Add( mPopup );
     mPopup.SetDisplayState( Popup::SHOWN );
 
     return true;
   }
 
-  TextField CreateTextField( const Vector2& stageSize, const std::string& text )
+  TextField CreateTextField( const Vector2& windowSize, const std::string& text )
   {
     TextField field = TextField::New();
     field.SetProperty( Dali::Actor::Property::NAME,"textField");
@@ -116,7 +116,7 @@ public:
     field.SetProperty( TextField::Property::TEXT_COLOR, Vector4( 0.0f, 1.0f, 1.0f, 1.0f ) ); // CYAN
     field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Unnamed folder" );
     field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Enter folder name." );
-    field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( BORDER_WIDTH, BORDER_WIDTH, stageSize.width - BORDER_WIDTH*2, stageSize.height - BORDER_WIDTH*2 ) );
+    field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( BORDER_WIDTH, BORDER_WIDTH, windowSize.width - BORDER_WIDTH*2, windowSize.height - BORDER_WIDTH*2 ) );
 
     return field;
   }
@@ -128,7 +128,7 @@ public:
     popup.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
     popup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::WIDTH );
     popup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
-    popup.TouchSignal().Connect( this, &TextFieldExample::OnPopupTouched );
+    popup.TouchedSignal().Connect( this, &TextFieldExample::OnPopupTouched );
 
     return popup;
   }
@@ -151,10 +151,10 @@ public:
     mField.Reset();
   }
 
-  bool OnPopupTouched( Actor actor, const TouchData& event )
+  bool OnPopupTouched( Actor actor, const TouchEvent& event )
   {
     // End edit mode for TextField if parent Popup touched.
-    if(event.GetPointCount() > 0)
+    if((event.GetPointCount() > 0) && (mPopup == event.GetHitActor(0)))
     {
       switch( event.GetState( 0 ) )
       {
@@ -177,7 +177,7 @@ public:
       } // end switch
     }
 
-    return true;
+    return false;
   }
 
   /**
@@ -185,7 +185,7 @@ public:
    */
   void OnKeyEvent(const KeyEvent& event)
   {
-    if(event.state == KeyEvent::Down)
+    if(event.GetState() == KeyEvent::DOWN)
     {
       if( IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK ) )
       {