X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-field-impl.cpp;h=15ea36350a96b68680751faac771cf42ee481047;hp=cb820b1d6791bcac874ffe466a9839f26a9d0334;hb=1c6aa75cb7b66fdab6bff180c19066204171ef1e;hpb=fb87251cfeff34418a36798700b81786e522018a diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index cb820b1..15ea363 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,10 +33,10 @@ // INTERNAL INCLUDES #include #include -#include #include #include #include +#include #include #include #include @@ -137,12 +137,15 @@ DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "selectedTextStar DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "selectedTextEnd", INTEGER, SELECTED_TEXT_END ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "enableEditing", BOOLEAN, ENABLE_EDITING ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "fontSizeScale", FLOAT, FONT_SIZE_SCALE ) +DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "enableFontSizeScale", BOOLEAN, ENABLE_FONT_SIZE_SCALE ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "primaryCursorPosition", INTEGER, PRIMARY_CURSOR_POSITION ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "grabHandleColor", VECTOR4, GRAB_HANDLE_COLOR ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "inputFilter", MAP, INPUT_FILTER ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "ellipsisPosition", INTEGER, ELLIPSIS_POSITION ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "strikethrough", MAP, STRIKETHROUGH ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "inputStrikethrough", MAP, INPUT_STRIKETHROUGH ) +DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "characterSpacing", FLOAT, CHARACTER_SPACING ) +DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "selectionPopupStyle", MAP, SELECTION_POPUP_STYLE ) DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED ) DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED ) @@ -152,6 +155,7 @@ DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "inputFiltered", SIGNAL_INP DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "cursorPositionChanged", SIGNAL_CURSOR_POSITION_CHANGED) DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "selectionChanged", SIGNAL_SELECTION_CHANGED ) DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "selectionCleared", SIGNAL_SELECTION_CLEARED ) +DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "selectionStarted", SIGNAL_SELECTION_STARTED ) DALI_TYPE_REGISTRATION_END() // clang-format on @@ -203,28 +207,6 @@ Toolkit::TextField::InputStyle::Mask ConvertInputStyle(Text::InputStyle::Mask in return fieldInputStyleMask; } -bool IsHiddenInput(Toolkit::TextField textField) -{ - Property::Map hiddenInputSettings = textField.GetProperty(Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS); - auto mode = hiddenInputSettings.Find(Toolkit::HiddenInput::Property::MODE); - if(mode && (mode->Get() != Toolkit::HiddenInput::Mode::HIDE_NONE)) - { - return true; - } - return false; -} - -char GetSubstituteCharacter(Toolkit::TextField textField) -{ - Property::Map hiddenInputSettings = textField.GetProperty(Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS); - auto substChar = hiddenInputSettings.Find(Toolkit::HiddenInput::Property::SUBSTITUTE_CHARACTER); - if(substChar) - { - return static_cast(substChar->Get()); - } - return STAR; -} - } // namespace Toolkit::TextField TextField::New() @@ -416,6 +398,14 @@ bool TextField::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* fieldImpl.SelectionClearedSignal().Connect(tracker, functor); } } + else if(0 == strcmp(signalName.c_str(), SIGNAL_SELECTION_STARTED)) + { + if(field) + { + Internal::TextField& fieldImpl(GetImpl(field)); + fieldImpl.SelectionStartedSignal().Connect(tracker, functor); + } + } else { // signalName does not match any signal @@ -465,6 +455,11 @@ DevelTextField::SelectionClearedSignalType& TextField::SelectionClearedSignal() return mSelectionClearedSignal; } +DevelTextField::SelectionStartedSignalType& TextField::SelectionStartedSignal() +{ + return mSelectionStartedSignal; +} + void TextField::OnAccessibilityStatusChanged() { CommonTextUtils::SynchronizeTextAnchorsInParent(Self(), mController, mAnchorActors); @@ -534,9 +529,6 @@ void TextField::OnInitialize() self.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT); self.OnSceneSignal().Connect(this, &TextField::OnSceneConnect); - //Enable highightability - self.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true); - DevelControl::SetInputMethodContext(*this, mInputMethodContext); if(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy) @@ -544,15 +536,19 @@ void TextField::OnInitialize() EnableClipping(); } - DevelControl::SetAccessibilityConstructor(self, [](Dali::Actor actor) { - return std::unique_ptr( - new AccessibleImpl(actor, Dali::Accessibility::Role::ENTRY)); - }); + // Accessibility + self.SetProperty(DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::ENTRY); + self.SetProperty(DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true); Accessibility::Bridge::EnabledSignal().Connect(this, &TextField::OnAccessibilityStatusChanged); Accessibility::Bridge::DisabledSignal().Connect(this, &TextField::OnAccessibilityStatusChanged); } +DevelControl::ControlAccessible* TextField::CreateAccessibleObject() +{ + return new TextFieldAccessible(Self()); +} + void TextField::OnStyleChange(Toolkit::StyleManager styleManager, StyleChange::Type change) { DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::OnStyleChange\n"); @@ -613,6 +609,31 @@ void TextField::ResizeActor(Actor& actor, const Vector2& size) } } +void TextField::OnPropertySet(Property::Index index, const Property::Value& propertyValue) +{ + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::OnPropertySet index[%d]\n", index); + + switch(index) + { + case DevelActor::Property::USER_INTERACTION_ENABLED: + { + const bool enabled = propertyValue.Get(); + mController->SetUserInteractionEnabled(enabled); + if(mStencil) + { + float opacity = enabled ? 1.0f : mController->GetDisabledColorOpacity(); + mStencil.SetProperty(Actor::Property::OPACITY, opacity); + } + break; + } + default: + { + Control::OnPropertySet(index, propertyValue); // up call to control for non-handled properties + break; + } + } +} + void TextField::OnRelayout(const Vector2& size, RelayoutContainer& container) { DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField OnRelayout\n"); @@ -642,6 +663,11 @@ void TextField::OnRelayout(const Vector2& size, RelayoutContainer& container) mActiveLayer.SetProperty(Actor::Property::POSITION, Vector2(padding.start, padding.top)); ResizeActor(mActiveLayer, contentSize); } + if(mCursorLayer) + { + mCursorLayer.SetProperty(Actor::Property::POSITION, Vector2(padding.start, padding.top)); + ResizeActor(mCursorLayer, contentSize); + } // If there is text changed, callback is called. if(mTextChanged) @@ -675,6 +701,11 @@ void TextField::OnRelayout(const Vector2& size, RelayoutContainer& container) EmitCursorPositionChangedSignal(); } + if(mSelectionStarted) + { + EmitSelectionStartedSignal(); + } + if(mSelectionChanged) { EmitSelectionChangedSignal(); @@ -712,7 +743,7 @@ Text::ControllerPtr TextField::GetTextController() void TextField::RenderText(Text::Controller::UpdateTextType updateTextType) { - CommonTextUtils::RenderText(Self(), mRenderer, mController, mDecorator, mAlignmentOffset, mRenderableActor, mBackgroundActor, mStencil, mClippingDecorationActors, mAnchorActors, updateTextType); + CommonTextUtils::RenderText(Self(), mRenderer, mController, mDecorator, mAlignmentOffset, mRenderableActor, mBackgroundActor, mCursorLayer, mStencil, mClippingDecorationActors, mAnchorActors, updateTextType); } void TextField::OnKeyInputFocusGained() @@ -741,7 +772,10 @@ void TextField::OnKeyInputFocusGained() notifier.ContentSelectedSignal().Connect(this, &TextField::OnClipboardTextSelected); } - mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event + if(IsEditable() && mController->IsUserInteractionEnabled()) + { + mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event + } EmitKeyInputFocusSignal(true); // Calls back into the Control hence done last. } @@ -792,12 +826,21 @@ void TextField::OnTap(const TapGesture& gesture) mController->TapEvent(gesture.GetNumberOfTaps(), localPoint.x - padding.start, localPoint.y - padding.top); mController->AnchorEvent(localPoint.x - padding.start, localPoint.y - padding.top); + Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get(); + if (keyboardFocusManager) + { + keyboardFocusManager.SetCurrentFocusActor(Self()); + } SetKeyInputFocus(); } void TextField::OnPan(const PanGesture& gesture) { mController->PanEvent(gesture.GetState(), gesture.GetDisplacement()); + if(gesture.GetState() == GestureState::STARTED && !mController->IsScrollable(gesture.GetDisplacement())) + { + Dali::DevelActor::SetNeedGesturePropagation(Self(), true); + } } void TextField::OnLongPress(const LongPressGesture& gesture) @@ -823,6 +866,11 @@ bool TextField::OnKeyEvent(const KeyEvent& event) // Make sure ClearKeyInputFocus when only key is up if(event.GetState() == KeyEvent::UP) { + Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get(); + if (keyboardFocusManager) + { + keyboardFocusManager.ClearFocus(); + } ClearKeyInputFocus(); } @@ -858,26 +906,17 @@ void TextField::SetEditable(bool editable) void TextField::TextInserted(unsigned int position, unsigned int length, const std::string& content) { - if(Accessibility::IsUp()) - { - Control::Impl::GetAccessibilityObject(Self())->EmitTextInserted(position, length, content); - } + GetAccessibleObject()->EmitTextInserted(position, length, content); } void TextField::TextDeleted(unsigned int position, unsigned int length, const std::string& content) { - if(Accessibility::IsUp()) - { - Control::Impl::GetAccessibilityObject(Self())->EmitTextDeleted(position, length, content); - } + GetAccessibleObject()->EmitTextDeleted(position, length, content); } void TextField::CursorPositionChanged(unsigned int oldPosition, unsigned int newPosition) { - if(Accessibility::IsUp()) - { - Control::Impl::GetAccessibilityObject(Self())->EmitTextCursorMoved(newPosition); - } + GetAccessibleObject()->EmitTextCursorMoved(newPosition); if((oldPosition != newPosition) && !mCursorPositionChanged) { @@ -950,6 +989,13 @@ void TextField::EmitSelectionClearedSignal() mSelectionCleared = false; } +void TextField::EmitSelectionStartedSignal() +{ + Dali::Toolkit::TextField handle(GetOwner()); + mSelectionStartedSignal.Emit(handle); + mSelectionStarted = false; +} + void TextField::SelectionChanged(uint32_t oldStart, uint32_t oldEnd, uint32_t newStart, uint32_t newEnd) { if(((oldStart != newStart) || (oldEnd != newEnd)) && !mSelectionChanged) @@ -958,6 +1004,13 @@ void TextField::SelectionChanged(uint32_t oldStart, uint32_t oldEnd, uint32_t ne { mSelectionCleared = true; } + else + { + if(oldStart == oldEnd) + { + mSelectionStarted = true; + } + } mSelectionChanged = true; mOldSelectionStart = oldStart; @@ -973,7 +1026,7 @@ void TextField::SelectionChanged(uint32_t oldStart, uint32_t oldEnd, uint32_t ne } } -void TextField::AddDecoration(Actor& actor, bool needsClipping) +void TextField::AddDecoration(Actor& actor, DecorationType type, bool needsClipping) { if(actor) { @@ -981,16 +1034,27 @@ void TextField::AddDecoration(Actor& actor, bool needsClipping) { mClippingDecorationActors.push_back(actor); } - else + + // If the actor is a layer type, add it. + if(type == DecorationType::ACTIVE_LAYER) + { + AddLayer(mActiveLayer, actor); + } + else if(type == DecorationType::CURSOR_LAYER) { - actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); - actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); - Self().Add(actor); - mActiveLayer = actor; + AddLayer(mCursorLayer, actor); } } } +void TextField::AddLayer(Actor& layer, Actor& actor) +{ + actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + Self().Add(actor); + layer = actor; +} + void TextField::GetControlBackgroundColor(Vector4& color) const { Property::Value propValue = Self().GetProperty(Toolkit::Control::Property::BACKGROUND); @@ -1116,7 +1180,8 @@ TextField::TextField() mSelectionCleared(false), mOldPosition(0u), mOldSelectionStart(0u), - mOldSelectionEnd(0u) + mOldSelectionEnd(0u), + mSelectionStarted(false) { } @@ -1140,322 +1205,59 @@ Vector TextField::GetTextPosition(const uint32_t startIndex, const uint return mController->GetTextPosition(startIndex, endIndex); } -std::string TextField::AccessibleImpl::GetName() +std::string TextField::TextFieldAccessible::GetName() const { - auto self = Toolkit::TextField::DownCast(Self()); - if(IsHiddenInput(self)) + if(IsHiddenInput()) { return {}; } - return self.GetProperty(Toolkit::TextField::Property::TEXT).Get(); + return GetWholeText(); } -std::string TextField::AccessibleImpl::GetText(size_t startOffset, size_t endOffset) +const std::vector& TextField::TextFieldAccessible::GetTextAnchors() const { - if(endOffset <= startOffset) - { - return {}; - } - auto self = Toolkit::TextField::DownCast(Self()); - auto text = self.GetProperty(Toolkit::TextField::Property::TEXT).Get(); - if(startOffset > text.size() || endOffset > text.size()) - { - return {}; - } - if(IsHiddenInput(self)) - { - return std::string(endOffset - startOffset, GetSubstituteCharacter(self)); - } - return text.substr(startOffset, endOffset - startOffset); + return Toolkit::GetImpl(self).mAnchorActors; } -size_t TextField::AccessibleImpl::GetCharacterCount() +Toolkit::Text::ControllerPtr TextField::TextFieldAccessible::GetTextController() const { auto self = Toolkit::TextField::DownCast(Self()); - auto text = self.GetProperty(Toolkit::TextField::Property::TEXT).Get(); - return text.size(); -} - -size_t TextField::AccessibleImpl::GetCursorOffset() -{ - auto self = Toolkit::TextField::DownCast(Self()); - return Dali::Toolkit::GetImpl(self).GetTextController()->GetCursorPosition(); + return Toolkit::GetImpl(self).GetTextController(); } -bool TextField::AccessibleImpl::SetCursorOffset(size_t offset) +std::uint32_t TextField::TextFieldAccessible::GetSubstituteCharacter() const { - auto self = Toolkit::TextField::DownCast(Self()); - auto text = self.GetProperty(Toolkit::TextField::Property::TEXT).Get(); - if(offset > text.size()) - { - return false; - } + auto self = Toolkit::TextField::DownCast(Self()); + auto hiddenInputSettings = self.GetProperty(Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS); + auto substChar = hiddenInputSettings.Find(Toolkit::HiddenInput::Property::SUBSTITUTE_CHARACTER); - auto& selfImpl = Dali::Toolkit::GetImpl(self); - selfImpl.GetTextController()->ResetCursorPosition(offset); - selfImpl.RequestTextRelayout(); - - return true; -} - -Dali::Accessibility::Range TextField::AccessibleImpl::GetTextAtOffset( - size_t offset, Dali::Accessibility::TextBoundary boundary) -{ - auto self = Toolkit::TextField::DownCast(Self()); - auto range = Dali::Accessibility::Range{}; - - if(IsHiddenInput(self)) - { - // Returning empty object, as there is no possibility to parse the textfield - // when its content is hidden. - return range; - } - - auto text = self.GetProperty(Toolkit::TextField::Property::TEXT).Get(); - auto textSize = text.size(); - - switch(boundary) - { - case Dali::Accessibility::TextBoundary::CHARACTER: - { - if(offset < textSize) - { - range.content = text[offset]; - range.startOffset = offset; - range.endOffset = offset + 1; - } - break; - } - case Dali::Accessibility::TextBoundary::WORD: - case Dali::Accessibility::TextBoundary::LINE: - { - auto textString = text.c_str(); - auto breaks = std::vector(textSize, 0); - - if(boundary == Dali::Accessibility::TextBoundary::WORD) - { - Accessibility::Accessible::FindWordSeparationsUtf8(reinterpret_cast(textString), textSize, "", breaks.data()); - } - else - { - Accessibility::Accessible::FindLineSeparationsUtf8(reinterpret_cast(textString), textSize, "", breaks.data()); - } - - auto index = 0u; - auto counter = 0u; - while(index < textSize && counter <= offset) - { - auto start = index; - if(breaks[index]) - { - while(breaks[index]) - { - index++; - } - counter++; - } - else - { - if(boundary == Dali::Accessibility::TextBoundary::WORD) - { - index++; - } - if(boundary == Dali::Accessibility::TextBoundary::LINE) - { - counter++; - } - } - - if((counter > 0) && ((counter - 1) == offset)) - { - range.content = text.substr(start, index - start + 1); - range.startOffset = start; - range.endOffset = index + 1; - } - - if(boundary == Dali::Accessibility::TextBoundary::LINE) - { - index++; - } - } - break; - } - case Dali::Accessibility::TextBoundary::SENTENCE: - { - /* not supported by default */ - break; - } - case Dali::Accessibility::TextBoundary::PARAGRAPH: - { - /* Paragraph is not supported by libunibreak library */ - break; - } - default: - break; - } - - return range; -} - -Dali::Accessibility::Range TextField::AccessibleImpl::GetRangeOfSelection(size_t selectionIndex) -{ - // Since DALi supports only one selection indexes higher than 0 are ignored - if(selectionIndex > 0) - { - return {}; - } - - auto self = Toolkit::TextField::DownCast(Self()); - auto controller = Dali::Toolkit::GetImpl(self).GetTextController(); - auto indices = controller->GetSelectionIndexes(); - - auto startOffset = static_cast(indices.first); - auto endOffset = static_cast(indices.second); - - if(IsHiddenInput(self)) - { - return {startOffset, endOffset, std::string(endOffset - startOffset, GetSubstituteCharacter(self))}; - } - - std::string value{}; - controller->RetrieveSelection(value); - return {startOffset, endOffset, value}; -} - -bool TextField::AccessibleImpl::RemoveSelection(size_t selectionIndex) -{ - // Since DALi supports only one selection indexes higher than 0 are ignored - if(selectionIndex > 0) - { - return false; - } - - auto self = Toolkit::TextField::DownCast(Self()); - Dali::Toolkit::GetImpl(self).GetTextController()->SetSelection(0, 0); - return true; -} - -bool TextField::AccessibleImpl::SetRangeOfSelection(size_t selectionIndex, size_t startOffset, size_t endOffset) -{ - // Since DALi supports only one selection indexes higher than 0 are ignored - if(selectionIndex > 0) - { - return false; - } - - auto self = Toolkit::TextField::DownCast(Self()); - Dali::Toolkit::GetImpl(self).GetTextController()->SetSelection(startOffset, endOffset); - return true; -} - -bool TextField::AccessibleImpl::CopyText(size_t startPosition, size_t endPosition) -{ - if(endPosition <= startPosition) - { - return false; - } - - auto self = Toolkit::TextField::DownCast(Self()); - auto text = self.GetProperty(Toolkit::TextField::Property::TEXT).Get(); - Dali::Toolkit::GetImpl(self).GetTextController()->CopyStringToClipboard(text.substr(startPosition, endPosition - startPosition)); - - return true; -} - -bool TextField::AccessibleImpl::CutText(size_t startPosition, size_t endPosition) -{ - if(endPosition <= startPosition) - { - return false; - } - - auto self = Toolkit::TextField::DownCast(Self()); - auto text = self.GetProperty(Toolkit::TextField::Property::TEXT).Get(); - Dali::Toolkit::GetImpl(self).GetTextController()->CopyStringToClipboard(text.substr(startPosition, endPosition - startPosition)); - - self.SetProperty(Toolkit::TextField::Property::TEXT, text.substr(0, startPosition) + text.substr(endPosition)); - - return true; -} - -bool TextField::AccessibleImpl::DeleteText(size_t startPosition, size_t endPosition) -{ - if(endPosition <= startPosition) - { - return false; - } - - auto self = Toolkit::TextField::DownCast(Self()); - auto text = self.GetProperty(Toolkit::TextField::Property::TEXT).Get(); - - self.SetProperty(Toolkit::TextField::Property::TEXT, text.substr(0, startPosition) + text.substr(endPosition)); - - return true; -} - -Dali::Accessibility::States TextField::AccessibleImpl::CalculateStates() -{ - using namespace Dali::Accessibility; - - auto states = DevelControl::AccessibleImpl::CalculateStates(); - - states[State::EDITABLE] = true; - states[State::FOCUSABLE] = true; - - Toolkit::Control focusControl = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl(); - if(mSelf == focusControl) + if(substChar) { - states[State::FOCUSED] = true; + return static_cast(substChar->Get()); } - return states; + return TextControlAccessible::GetSubstituteCharacter(); } -bool TextField::AccessibleImpl::InsertText(size_t startPosition, std::string text) +bool TextField::TextFieldAccessible::IsHiddenInput() const { - auto self = Toolkit::TextField::DownCast(Self()); - auto insertedText = self.GetProperty(Toolkit::TextField::Property::TEXT).Get(); - - insertedText.insert(startPosition, text); + auto self = Toolkit::TextField::DownCast(Self()); + auto hiddenInputSettings = self.GetProperty(Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS); + auto mode = hiddenInputSettings.Find(Toolkit::HiddenInput::Property::MODE); - self.SetProperty(Toolkit::TextField::Property::TEXT, std::move(insertedText)); - - return true; + return (mode && (mode->Get() != Toolkit::HiddenInput::Mode::HIDE_NONE)); } -bool TextField::AccessibleImpl::SetTextContents(std::string newContents) +void TextField::TextFieldAccessible::RequestTextRelayout() { - auto self = Toolkit::TextField::DownCast(Self()); - self.SetProperty(Toolkit::TextField::Property::TEXT, std::move(newContents)); - return true; -} + auto self = Toolkit::TextField::DownCast(Self()); + auto& selfImpl = Toolkit::GetImpl(self); -int32_t TextField::AccessibleImpl::GetLinkCount() const -{ - auto self = Toolkit::TextField::DownCast(Self()); - return Dali::Toolkit::GetImpl(self).mAnchorActors.size(); -} - -Accessibility::Hyperlink* TextField::AccessibleImpl::GetLink(int32_t linkIndex) const -{ - if(linkIndex < 0 || linkIndex >= GetLinkCount()) - { - return nullptr; - } - auto self = Toolkit::TextField::DownCast(Self()); - auto anchorActor = Dali::Toolkit::GetImpl(self).mAnchorActors[linkIndex]; - return dynamic_cast(Dali::Accessibility::Accessible::Get(anchorActor)); -} - -int32_t TextField::AccessibleImpl::GetLinkIndex(int32_t characterOffset) const -{ - auto self = Toolkit::TextField::DownCast(Self()); - auto controller = Dali::Toolkit::GetImpl(self).GetTextController(); - return controller->GetAnchorIndex(static_cast(characterOffset)); + selfImpl.RequestTextRelayout(); } } // namespace Internal