Dali_test: add test for enable_editing 93/244493/2
authorAli Alzyod <ali198724@gmail.com>
Sun, 20 Sep 2020 14:18:21 +0000 (17:18 +0300)
committerali198724 <ali198724@gmail.com>
Wed, 7 Oct 2020 16:19:46 +0000 (19:19 +0300)
Change-Id: I949b883820d4b96b0ebadf01967d62e5be889fd7

examples/simple-text-field/simple-text-field.cpp

index 601e6a5..c62fb20 100644 (file)
@@ -59,7 +59,6 @@ public:
     mTextField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
     mTextField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 60.f));
     mTextField.SetBackgroundColor(Color::WHITE);
-    mTextField.SetBackgroundColor(Vector4(1.f, 1.f, 1.f, 0.15f));
 
     mTextField.SetProperty(TextField::Property::TEXT_COLOR, Color::BLACK);
     mTextField.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Unnamed folder");
@@ -82,12 +81,20 @@ public:
     mButtonSelectionEnd.SetProperty(Button::Property::LABEL, "select -->");
     mButtonSelectionEnd.ClickedSignal().Connect(this, &SimpleTextFieldExample::OnButtonClicked);
 
+    mBtnEditable = PushButton::New();
+    mBtnEditable.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+    mBtnEditable.SetProperty(Actor::Property::SIZE, Vector2(250.f, 80.f));
+    mBtnEditable.SetProperty(Actor::Property::POSITION, Vector2(0, 220.f));
+    mBtnEditable.SetBackgroundColor(Color::RED);
+    mBtnEditable.SetProperty(Button::Property::LABEL, "Non-editable");
+    mBtnEditable.ClickedSignal().Connect(this, &SimpleTextFieldExample::OnButtonClicked);
+
     window.Add(mTextField);
     window.Add(mButtonSelectionStart);
     window.Add(mButtonSelectionEnd);
+    window.Add(mBtnEditable);
   }
 
-
   bool OnButtonClicked(Button button)
   {
     if(button == mButtonSelectionStart)
@@ -103,6 +110,21 @@ public:
     {
       mTextField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END , mTextField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>() + 1);
     }
+    else if (mBtnEditable == button)
+    {
+      bool bEditable = !mTextField.GetProperty( DevelTextField::Property::ENABLE_EDITING).Get<int>();
+      mTextField.SetProperty( DevelTextField::Property::ENABLE_EDITING , bEditable);
+      if (bEditable)
+        {
+          mBtnEditable.SetProperty(Button::Property::LABEL, "Non-editable");
+          mBtnEditable.SetBackgroundColor(Color::RED);
+        }
+      else
+        {
+          mBtnEditable.SetProperty(Button::Property::LABEL, "editable");
+          mBtnEditable.SetBackgroundColor(Color::GREEN);
+        }
+    }
 
     return true;
   }
@@ -126,6 +148,7 @@ private:
   TextField mTextField;
   PushButton mButtonSelectionStart;
   PushButton mButtonSelectionEnd;
+  PushButton mBtnEditable;
 };
 
 void RunTest(Application& application)