Merge "[AT-SPI] Add SetTextContents, InsertText and DeleteText" into devel/master
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Tue, 1 Jun 2021 09:35:42 +0000 (09:35 +0000)
committerGerrit Code Review <gerrit@review>
Tue, 1 Jun 2021 09:35:42 +0000 (09:35 +0000)
1  2 
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.h

@@@ -148,7 -148,6 +148,7 @@@ DALI_DEVEL_PROPERTY_REGISTRATION(Toolki
  DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit,           TextEditor, "primaryCursorPosition",                INTEGER,   PRIMARY_CURSOR_POSITION             )
  DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit,           TextEditor, "grabHandleColor",                      VECTOR4,   GRAB_HANDLE_COLOR                   )
  DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit,           TextEditor, "enableGrabHandlePopup",                BOOLEAN,   ENABLE_GRAB_HANDLE_POPUP            )
 +DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit,           TextEditor, "inputMethodSettings",                  MAP,       INPUT_METHOD_SETTINGS               )
  
  DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "textChanged",        SIGNAL_TEXT_CHANGED       )
  DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "inputStyleChanged",  SIGNAL_INPUT_STYLE_CHANGED)
@@@ -785,22 -784,6 +785,22 @@@ void TextEditor::SetProperty(BaseObject
          impl.mController->SetGrabHandlePopupEnabled(grabHandlePopupEnabled);
          break;
        }
 +      case Toolkit::DevelTextEditor::Property::INPUT_METHOD_SETTINGS:
 +      {
 +        const Property::Map* map = value.GetMap();
 +        if(map)
 +        {
 +          impl.mInputMethodOptions.ApplyProperty(*map);
 +        }
 +        impl.mController->SetInputModePassword(impl.mInputMethodOptions.IsPassword());
 +
 +        Toolkit::Control control = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl();
 +        if(control == textEditor)
 +        {
 +          impl.mInputMethodContext.ApplyOptions(impl.mInputMethodOptions);
 +        }
 +        break;
 +      }
      } // switch
    }   // texteditor
  }
@@@ -1167,13 -1150,6 +1167,13 @@@ Property::Value TextEditor::GetProperty
          value = impl.mController->IsGrabHandlePopupEnabled();
          break;
        }
 +      case Toolkit::DevelTextEditor::Property::INPUT_METHOD_SETTINGS:
 +      {
 +        Property::Map map;
 +        impl.mInputMethodOptions.RetrieveProperty(map);
 +        value = map;
 +        break;
 +      }
      } //switch
    }
  
@@@ -1593,7 -1569,6 +1593,7 @@@ void TextEditor::OnKeyInputFocusGained(
    if(mInputMethodContext && IsEditable())
    {
      // All input panel properties, such as layout, return key type, and input hint, should be set before input panel activates (or shows).
 +    mInputMethodContext.ApplyOptions(mInputMethodOptions);
      mInputMethodContext.NotifyTextInputMultiLine(true);
  
      mInputMethodContext.StatusChangedSignal().Connect(this, &TextEditor::KeyboardStatusChanged);
@@@ -2286,7 -2261,22 +2286,22 @@@ bool TextEditor::AccessibleImpl::CutTex
    Dali::Toolkit::GetImpl(slf).getController()->CopyStringToClipboard(txt.substr(startPosition, endPosition - startPosition));
  
    slf.SetProperty(Toolkit::TextEditor::Property::TEXT,
-                   txt.substr(0, startPosition) + txt.substr(endPosition - startPosition, txt.size()));
+                   txt.substr(0, startPosition) + txt.substr(endPosition));
+   return true;
+ }
+ bool TextEditor::AccessibleImpl::DeleteText(size_t startPosition,
+                                             size_t endPosition)
+ {
+   if(endPosition <= startPosition)
+     return false;
+   auto slf = Toolkit::TextEditor::DownCast(Self());
+   auto txt = slf.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
+   slf.SetProperty(Toolkit::TextEditor::Property::TEXT,
+                   txt.substr(0, startPosition) + txt.substr(endPosition));
  
    return true;
  }
@@@ -2308,6 -2298,26 +2323,26 @@@ Dali::Accessibility::States TextEditor:
    return states;
  }
  
+ bool TextEditor::AccessibleImpl::InsertText(size_t startPosition,
+                                             std::string text)
+ {
+   auto slf = Toolkit::TextEditor::DownCast(Self());
+   auto txt = slf.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
+   txt.insert(startPosition, text);
+   slf.SetProperty(Toolkit::TextEditor::Property::TEXT, std::move(txt));
+   return true;
+ }
+ bool TextEditor::AccessibleImpl::SetTextContents(std::string newContents)
+ {
+   auto slf = Toolkit::TextEditor::DownCast(Self());
+   slf.SetProperty(Toolkit::TextEditor::Property::TEXT, std::move(newContents));
+   return true;
+ }
  } // namespace Internal
  
  } // namespace Toolkit
@@@ -409,7 -409,6 +409,7 @@@ private: // Dat
    Dali::Animation               mAnimation; ///< Scroll indicator Show/Hide Animation.
    Dali::TimePeriod              mAnimationPeriod;
    std::vector<Actor>            mClippingDecorationActors; ///< Decoration actors which need clipping.
 +  Dali::InputMethodOptions      mInputMethodOptions;
  
    Actor         mRenderableActor;
    Actor         mActiveLayer;
      bool                  CopyText(size_t startPosition, size_t endPosition) override;
      bool                  CutText(size_t startPosition, size_t endPosition) override;
      Accessibility::States CalculateStates() override;
+     bool                  InsertText(size_t startPosition, std::string text) override;
+     bool                  SetTextContents(std::string newContents) override;
+     bool                  DeleteText(size_t startPosition, size_t endPosition) override;
    };
  };