2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/controls/text-controls/text-field-impl.h>
22 #include <dali/devel-api/actors/actor-devel.h>
23 #include <dali/devel-api/adaptor-framework/key-devel.h>
24 #include <dali/devel-api/common/stage.h>
25 #include <dali/devel-api/object/property-helper-devel.h>
26 #include <dali/integration-api/debug.h>
27 #include <dali/public-api/actors/layer.h>
28 #include <dali/public-api/adaptor-framework/key.h>
29 #include <dali/public-api/common/dali-common.h>
30 #include <dali/public-api/object/type-registry-helper.h>
34 #include <dali-toolkit/devel-api/controls/control-devel.h>
35 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
36 #include <dali-toolkit/devel-api/text/rendering-backend.h>
37 #include <dali-toolkit/internal/controls/text-controls/common-text-utils.h>
38 #include <dali-toolkit/internal/controls/text-controls/text-field-property-handler.h>
39 #include <dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h>
40 #include <dali-toolkit/internal/styling/style-manager-impl.h>
41 #include <dali-toolkit/internal/text/rendering/text-backend.h>
42 #include <dali-toolkit/internal/text/text-effects-style.h>
43 #include <dali-toolkit/internal/text/text-enumerations-impl.h>
44 #include <dali-toolkit/internal/text/text-font-style.h>
45 #include <dali-toolkit/internal/text/text-view.h>
46 #include <dali-toolkit/public-api/text/text-enumerations.h>
47 #include <dali-toolkit/public-api/visuals/color-visual-properties.h>
48 #include <dali-toolkit/public-api/visuals/visual-properties.h>
49 #include <dali/integration-api/adaptor-framework/adaptor.h>
51 using namespace Dali::Toolkit::Text;
53 #if defined(DEBUG_ENABLED)
54 Debug::Filter* gTextFieldLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS");
63 namespace // unnamed namespace
65 const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::DevelText::DEFAULT_RENDERING_BACKEND;
66 const char* KEY_RETURN_NAME = "Return";
67 } // unnamed namespace
74 return Toolkit::TextField::New();
78 // Setup properties, signals and actions using the type-registry.
79 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextField, Toolkit::Control, Create );
81 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "text", STRING, TEXT )
82 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "placeholderText", STRING, PLACEHOLDER_TEXT )
83 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "placeholderTextFocused", STRING, PLACEHOLDER_TEXT_FOCUSED )
84 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "fontFamily", STRING, FONT_FAMILY )
85 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "fontStyle", MAP, FONT_STYLE )
86 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "pointSize", FLOAT, POINT_SIZE )
87 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "maxLength", INTEGER, MAX_LENGTH )
88 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "exceedPolicy", INTEGER, EXCEED_POLICY )
89 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "horizontalAlignment", STRING, HORIZONTAL_ALIGNMENT )
90 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "verticalAlignment", STRING, VERTICAL_ALIGNMENT )
91 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "textColor", VECTOR4, TEXT_COLOR )
92 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "placeholderTextColor", VECTOR4, PLACEHOLDER_TEXT_COLOR )
93 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "primaryCursorColor", VECTOR4, PRIMARY_CURSOR_COLOR )
94 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "secondaryCursorColor", VECTOR4, SECONDARY_CURSOR_COLOR )
95 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "enableCursorBlink", BOOLEAN, ENABLE_CURSOR_BLINK )
96 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "cursorBlinkInterval", FLOAT, CURSOR_BLINK_INTERVAL )
97 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "cursorBlinkDuration", FLOAT, CURSOR_BLINK_DURATION )
98 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "cursorWidth", INTEGER, CURSOR_WIDTH )
99 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "grabHandleImage", STRING, GRAB_HANDLE_IMAGE )
100 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "grabHandlePressedImage", STRING, GRAB_HANDLE_PRESSED_IMAGE )
101 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "scrollThreshold", FLOAT, SCROLL_THRESHOLD )
102 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "scrollSpeed", FLOAT, SCROLL_SPEED )
103 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "selectionHandleImageLeft", MAP, SELECTION_HANDLE_IMAGE_LEFT )
104 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "selectionHandleImageRight", MAP, SELECTION_HANDLE_IMAGE_RIGHT )
105 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "selectionHandlePressedImageLeft", MAP, SELECTION_HANDLE_PRESSED_IMAGE_LEFT )
106 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "selectionHandlePressedImageRight", MAP, SELECTION_HANDLE_PRESSED_IMAGE_RIGHT)
107 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "selectionHandleMarkerImageLeft", MAP, SELECTION_HANDLE_MARKER_IMAGE_LEFT )
108 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "selectionHandleMarkerImageRight", MAP, SELECTION_HANDLE_MARKER_IMAGE_RIGHT )
109 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "selectionHighlightColor", VECTOR4, SELECTION_HIGHLIGHT_COLOR )
110 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "decorationBoundingBox", RECTANGLE, DECORATION_BOUNDING_BOX )
111 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputMethodSettings", MAP, INPUT_METHOD_SETTINGS )
112 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputColor", VECTOR4, INPUT_COLOR )
113 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "enableMarkup", BOOLEAN, ENABLE_MARKUP )
114 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputFontFamily", STRING, INPUT_FONT_FAMILY )
115 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputFontStyle", MAP, INPUT_FONT_STYLE )
116 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputPointSize", FLOAT, INPUT_POINT_SIZE )
117 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "underline", MAP, UNDERLINE )
118 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputUnderline", MAP, INPUT_UNDERLINE )
119 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "shadow", MAP, SHADOW )
120 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputShadow", MAP, INPUT_SHADOW )
121 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "emboss", MAP, EMBOSS )
122 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputEmboss", MAP, INPUT_EMBOSS )
123 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "outline", MAP, OUTLINE )
124 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputOutline", MAP, INPUT_OUTLINE )
125 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "hiddenInputSettings", MAP, HIDDEN_INPUT_SETTINGS )
126 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "pixelSize", FLOAT, PIXEL_SIZE )
127 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "enableSelection", BOOLEAN, ENABLE_SELECTION )
128 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "placeholder", MAP, PLACEHOLDER )
129 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "ellipsis", BOOLEAN, ELLIPSIS )
130 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "enableShiftSelection", BOOLEAN, ENABLE_SHIFT_SELECTION )
131 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "enableGrabHandle", BOOLEAN, ENABLE_GRAB_HANDLE )
132 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "matchSystemLanguageDirection", BOOLEAN, MATCH_SYSTEM_LANGUAGE_DIRECTION )
133 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "enableGrabHandlePopup", BOOLEAN, ENABLE_GRAB_HANDLE_POPUP )
134 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "textBackground", VECTOR4, BACKGROUND )
135 DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY(Toolkit, TextField, "selectedText", STRING, SELECTED_TEXT )
136 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "renderingBackend", INTEGER, RENDERING_BACKEND )
137 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "selectedTextStart", INTEGER, SELECTED_TEXT_START )
138 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "selectedTextEnd", INTEGER, SELECTED_TEXT_END )
139 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "enableEditing", BOOLEAN, ENABLE_EDITING )
140 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "fontSizeScale", FLOAT, FONT_SIZE_SCALE )
141 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "enableFontSizeScale", BOOLEAN, ENABLE_FONT_SIZE_SCALE )
142 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "primaryCursorPosition", INTEGER, PRIMARY_CURSOR_POSITION )
143 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "grabHandleColor", VECTOR4, GRAB_HANDLE_COLOR )
144 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "inputFilter", MAP, INPUT_FILTER )
145 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "ellipsisPosition", INTEGER, ELLIPSIS_POSITION )
146 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "strikethrough", MAP, STRIKETHROUGH )
147 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "inputStrikethrough", MAP, INPUT_STRIKETHROUGH )
148 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "characterSpacing", FLOAT, CHARACTER_SPACING )
149 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "selectionPopupStyle", MAP, SELECTION_POPUP_STYLE )
151 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED )
152 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED )
153 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED )
154 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "anchorClicked", SIGNAL_ANCHOR_CLICKED )
155 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "inputFiltered", SIGNAL_INPUT_FILTERED )
156 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "cursorPositionChanged", SIGNAL_CURSOR_POSITION_CHANGED)
157 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "selectionChanged", SIGNAL_SELECTION_CHANGED )
158 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "selectionCleared", SIGNAL_SELECTION_CLEARED )
159 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "selectionStarted", SIGNAL_SELECTION_STARTED )
161 DALI_TYPE_REGISTRATION_END()
164 Toolkit::TextField::InputStyle::Mask ConvertInputStyle(Text::InputStyle::Mask inputStyleMask)
166 Toolkit::TextField::InputStyle::Mask fieldInputStyleMask = Toolkit::TextField::InputStyle::NONE;
168 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_COLOR))
170 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::COLOR);
172 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_FONT_FAMILY))
174 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_FAMILY);
176 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_POINT_SIZE))
178 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::POINT_SIZE);
180 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_FONT_WEIGHT))
182 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE);
184 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_FONT_WIDTH))
186 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE);
188 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_FONT_SLANT))
190 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE);
192 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_UNDERLINE))
194 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::UNDERLINE);
196 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_SHADOW))
198 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::SHADOW);
200 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_EMBOSS))
202 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::EMBOSS);
204 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_OUTLINE))
206 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::OUTLINE);
208 return fieldInputStyleMask;
213 Toolkit::TextField TextField::New(ControlBehaviour additionalBehaviour)
215 // Create the implementation, temporarily owned by this handle on stack
216 IntrusivePtr<TextField> impl = new TextField(additionalBehaviour);
218 // Pass ownership to CustomActor handle
219 Toolkit::TextField handle(*impl);
221 // Second-phase init of the implementation
222 // This can only be done after the CustomActor connection has been made...
228 void TextField::SetProperty(BaseObject* object, Property::Index index, const Property::Value& value)
230 Toolkit::TextField textField = Toolkit::TextField::DownCast(Dali::BaseHandle(object));
232 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField SetProperty\n");
236 PropertyHandler::SetProperty(textField, index, value);
240 Property::Value TextField::GetProperty(BaseObject* object, Property::Index index)
242 Property::Value value;
244 Toolkit::TextField textField = Toolkit::TextField::DownCast(Dali::BaseHandle(object));
248 value = PropertyHandler::GetProperty(textField, index);
254 void TextField::SelectWholeText()
256 if(mController && mController->IsShowingRealText())
258 mController->SelectWholeText();
263 void TextField::SelectNone()
265 if(mController && mController->IsShowingRealText())
267 mController->SelectNone();
271 void TextField::SelectText(const uint32_t start, const uint32_t end)
273 if(mController && mController->IsShowingRealText())
275 mController->SelectText(start, end);
280 string TextField::GetSelectedText() const
282 string selectedText = "";
283 if(mController && mController->IsShowingRealText())
285 selectedText = mController->GetSelectedText();
290 void TextField::SetTextSelectionRange(const uint32_t* start, const uint32_t* end)
292 if(mController && mController->IsShowingRealText())
294 mController->SetTextSelectionRange(start, end);
299 Uint32Pair TextField::GetTextSelectionRange() const
302 if(mController && mController->IsShowingRealText())
304 range = mController->GetTextSelectionRange();
309 string TextField::CopyText()
311 string copiedText = "";
312 if(mController && mController->IsShowingRealText())
314 copiedText = mController->CopyText();
319 string TextField::CutText()
322 if(mController && mController->IsShowingRealText())
324 cutText = mController->CutText();
329 void TextField::PasteText()
333 SetKeyInputFocus(); //Giving focus to the field that was passed to the PasteText in case the passed field (current field) doesn't have focus.
334 mController->PasteText();
338 InputMethodContext TextField::GetInputMethodContext()
340 return mInputMethodContext;
343 bool TextField::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
345 Dali::BaseHandle handle(object);
347 bool connected(true);
348 Toolkit::TextField field = Toolkit::TextField::DownCast(handle);
350 if(0 == strcmp(signalName.c_str(), SIGNAL_TEXT_CHANGED))
352 field.TextChangedSignal().Connect(tracker, functor);
354 else if(0 == strcmp(signalName.c_str(), SIGNAL_MAX_LENGTH_REACHED))
356 field.MaxLengthReachedSignal().Connect(tracker, functor);
358 else if(0 == strcmp(signalName.c_str(), SIGNAL_INPUT_STYLE_CHANGED))
360 field.InputStyleChangedSignal().Connect(tracker, functor);
362 else if(0 == strcmp(signalName.c_str(), SIGNAL_ANCHOR_CLICKED))
366 Internal::TextField& fieldImpl(GetImpl(field));
367 fieldImpl.AnchorClickedSignal().Connect(tracker, functor);
370 else if(0 == strcmp(signalName.c_str(), SIGNAL_CURSOR_POSITION_CHANGED))
374 Internal::TextField& fieldImpl(GetImpl(field));
375 fieldImpl.CursorPositionChangedSignal().Connect(tracker, functor);
378 else if(0 == strcmp(signalName.c_str(), SIGNAL_INPUT_FILTERED))
382 Internal::TextField& fieldImpl(GetImpl(field));
383 fieldImpl.InputFilteredSignal().Connect(tracker, functor);
386 else if(0 == strcmp(signalName.c_str(), SIGNAL_SELECTION_CHANGED))
390 Internal::TextField& fieldImpl(GetImpl(field));
391 fieldImpl.SelectionChangedSignal().Connect(tracker, functor);
394 else if(0 == strcmp(signalName.c_str(), SIGNAL_SELECTION_CLEARED))
398 Internal::TextField& fieldImpl(GetImpl(field));
399 fieldImpl.SelectionClearedSignal().Connect(tracker, functor);
402 else if(0 == strcmp(signalName.c_str(), SIGNAL_SELECTION_STARTED))
406 Internal::TextField& fieldImpl(GetImpl(field));
407 fieldImpl.SelectionStartedSignal().Connect(tracker, functor);
412 // signalName does not match any signal
419 Toolkit::TextField::TextChangedSignalType& TextField::TextChangedSignal()
421 return mTextChangedSignal;
424 Toolkit::TextField::MaxLengthReachedSignalType& TextField::MaxLengthReachedSignal()
426 return mMaxLengthReachedSignal;
429 Toolkit::TextField::InputStyleChangedSignalType& TextField::InputStyleChangedSignal()
431 return mInputStyleChangedSignal;
434 DevelTextField::AnchorClickedSignalType& TextField::AnchorClickedSignal()
436 return mAnchorClickedSignal;
439 DevelTextField::CursorPositionChangedSignalType& TextField::CursorPositionChangedSignal()
441 return mCursorPositionChangedSignal;
444 DevelTextField::InputFilteredSignalType& TextField::InputFilteredSignal()
446 return mInputFilteredSignal;
449 DevelTextField::SelectionChangedSignalType& TextField::SelectionChangedSignal()
451 return mSelectionChangedSignal;
454 DevelTextField::SelectionClearedSignalType& TextField::SelectionClearedSignal()
456 return mSelectionClearedSignal;
459 DevelTextField::SelectionStartedSignalType& TextField::SelectionStartedSignal()
461 return mSelectionStartedSignal;
464 void TextField::OnAccessibilityStatusChanged()
466 CommonTextUtils::SynchronizeTextAnchorsInParent(Self(), mController, mAnchorActors);
469 void TextField::OnInitialize()
473 mController = Text::Controller::New(this, this, this, this);
475 // When using the vector-based rendering, the size of the GLyphs are different
476 TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
477 mController->SetGlyphType(glyphType);
479 mDecorator = Text::Decorator::New(*mController,
482 mInputMethodContext = InputMethodContext::New(self);
484 mController->GetLayoutEngine().SetLayout(Layout::Engine::SINGLE_LINE_BOX);
486 // Enables the text input.
487 mController->EnableTextInput(mDecorator, mInputMethodContext);
489 // Enables the horizontal scrolling after the text input has been enabled.
490 mController->SetHorizontalScrollEnabled(true);
492 // Disables the vertical scrolling.
493 mController->SetVerticalScrollEnabled(false);
495 // Disable the smooth handle panning.
496 mController->SetSmoothHandlePanEnabled(false);
498 mController->SetNoTextDoubleTapAction(Controller::NoTextTap::HIGHLIGHT);
499 mController->SetNoTextLongPressAction(Controller::NoTextTap::HIGHLIGHT);
501 // Sets layoutDirection value
502 Dali::Stage stage = Dali::Stage::GetCurrent();
503 Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>(stage.GetRootLayer().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
504 mController->SetLayoutDirection(layoutDirection);
506 self.LayoutDirectionChangedSignal().Connect(this, &TextField::OnLayoutDirectionChanged);
508 // Forward input events to controller
509 EnableGestureDetection(static_cast<GestureType::Value>(GestureType::TAP | GestureType::PAN | GestureType::LONG_PRESS));
510 GetTapGestureDetector().SetMaximumTapsRequired(2);
511 GetTapGestureDetector().ReceiveAllTapEvents(true);
513 self.TouchedSignal().Connect(this, &TextField::OnTouched);
515 // Set BoundingBox to stage size if not already set.
516 Rect<int> boundingBox;
517 mDecorator->GetBoundingBox(boundingBox);
519 if(boundingBox.IsEmpty())
521 Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
522 mDecorator->SetBoundingBox(Rect<int>(0.0f, 0.0f, stageSize.width, stageSize.height));
525 // Flip vertically the 'left' selection handle
526 mDecorator->FlipHandleVertically(LEFT_SELECTION_HANDLE, true);
528 // Fill-parent area by default
529 self.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
530 self.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT);
531 self.OnSceneSignal().Connect(this, &TextField::OnSceneConnect);
533 DevelControl::SetInputMethodContext(*this, mInputMethodContext);
535 if(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy)
541 self.SetProperty(DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::ENTRY);
542 self.SetProperty(DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true);
544 Accessibility::Bridge::EnabledSignal().Connect(this, &TextField::OnAccessibilityStatusChanged);
545 Accessibility::Bridge::DisabledSignal().Connect(this, &TextField::OnAccessibilityStatusChanged);
548 DevelControl::ControlAccessible* TextField::CreateAccessibleObject()
550 return new TextFieldAccessible(Self());
553 void TextField::OnStyleChange(Toolkit::StyleManager styleManager, StyleChange::Type change)
555 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::OnStyleChange\n");
559 case StyleChange::DEFAULT_FONT_CHANGE:
561 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n");
562 const std::string& newFont = GetImpl(styleManager).GetDefaultFontFamily();
563 // Property system did not set the font so should update it.
564 mController->UpdateAfterFontChange(newFont);
569 case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
571 GetImpl(styleManager).ApplyThemeStyle(Toolkit::Control(GetOwner()));
575 case StyleChange::THEME_CHANGE:
577 // Nothing to do, let control base class handle this
582 // Up call to Control
583 Control::OnStyleChange(styleManager, change);
586 Vector3 TextField::GetNaturalSize()
589 padding = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
591 Vector3 naturalSize = mController->GetNaturalSize();
592 naturalSize.width += (padding.start + padding.end);
593 naturalSize.height += (padding.top + padding.bottom);
598 float TextField::GetHeightForWidth(float width)
601 padding = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
602 return mController->GetHeightForWidth(width) + padding.top + padding.bottom;
605 void TextField::ResizeActor(Actor& actor, const Vector2& size)
607 if(actor.GetProperty<Vector3>(Dali::Actor::Property::SIZE).GetVectorXY() != size)
609 actor.SetProperty(Actor::Property::SIZE, size);
613 void TextField::OnPropertySet(Property::Index index, const Property::Value& propertyValue)
615 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::OnPropertySet index[%d]\n", index);
619 case DevelActor::Property::USER_INTERACTION_ENABLED:
621 const bool enabled = propertyValue.Get<bool>();
622 mController->SetUserInteractionEnabled(enabled);
625 float opacity = enabled ? 1.0f : mController->GetDisabledColorOpacity();
626 mStencil.SetProperty(Actor::Property::OPACITY, opacity);
632 Control::OnPropertySet(index, propertyValue); // up call to control for non-handled properties
638 void TextField::OnRelayout(const Vector2& size, RelayoutContainer& container)
640 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField OnRelayout\n");
645 padding = self.GetProperty<Extents>(Toolkit::Control::Property::PADDING);
647 Vector2 contentSize(size.x - (padding.start + padding.end), size.y - (padding.top + padding.bottom));
649 // Support Right-To-Left of padding
650 Dali::LayoutDirection::Type layoutDirection = mController->GetLayoutDirection(self);
652 if(Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection)
654 std::swap(padding.start, padding.end);
659 mStencil.SetProperty(Actor::Property::POSITION, Vector2(padding.start, padding.top));
660 ResizeActor(mStencil, contentSize);
664 mActiveLayer.SetProperty(Actor::Property::POSITION, Vector2(padding.start, padding.top));
665 ResizeActor(mActiveLayer, contentSize);
669 mCursorLayer.SetProperty(Actor::Property::POSITION, Vector2(padding.start, padding.top));
670 ResizeActor(mCursorLayer, contentSize);
673 // If there is text changed, callback is called.
676 EmitTextChangedSignal();
679 const Text::Controller::UpdateTextType updateTextType = mController->Relayout(contentSize, layoutDirection);
681 if((Text::Controller::NONE_UPDATED != updateTextType) ||
684 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::OnRelayout %p Displaying new contents\n", mController.Get());
687 (Text::Controller::NONE_UPDATED != (Text::Controller::DECORATOR_UPDATED & updateTextType)))
689 mDecorator->Relayout(contentSize);
694 mRenderer = Backend::Get().NewRenderer(mRenderingBackend);
697 RenderText(updateTextType);
700 if(mCursorPositionChanged)
702 EmitCursorPositionChangedSignal();
705 if(mSelectionStarted)
707 EmitSelectionStartedSignal();
710 if(mSelectionChanged)
712 EmitSelectionChangedSignal();
715 if(mSelectionCleared)
717 EmitSelectionClearedSignal();
720 // The text-field emits signals when the input style changes. These changes of style are
721 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
722 // can't be emitted during the size negotiation as the callbacks may update the UI.
723 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
724 if(!mController->IsInputStyleChangedSignalsQueueEmpty())
726 if(Adaptor::IsAvailable())
728 Adaptor& adaptor = Adaptor::Get();
730 if(NULL == mIdleCallback)
732 // @note: The callback manager takes the ownership of the callback object.
733 mIdleCallback = MakeCallback(this, &TextField::OnIdleSignal);
734 adaptor.AddIdle(mIdleCallback, false);
740 Text::ControllerPtr TextField::GetTextController()
745 void TextField::RenderText(Text::Controller::UpdateTextType updateTextType)
747 CommonTextUtils::RenderText(Self(), mRenderer, mController, mDecorator, mAlignmentOffset, mRenderableActor, mBackgroundActor, mCursorLayer, mStencil, mClippingDecorationActors, mAnchorActors, updateTextType);
750 void TextField::OnKeyInputFocusGained()
752 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get());
753 if(mInputMethodContext && IsEditable())
755 // All input panel properties, such as layout, return key type, and input hint, should be set before input panel activates (or shows).
756 mInputMethodContext.ApplyOptions(mInputMethodOptions);
757 mInputMethodContext.NotifyTextInputMultiLine(false);
759 mInputMethodContext.StatusChangedSignal().Connect(this, &TextField::KeyboardStatusChanged);
761 mInputMethodContext.EventReceivedSignal().Connect(this, &TextField::OnInputMethodContextEvent);
763 // Notify that the text editing start.
764 mInputMethodContext.Activate();
766 // When window gain lost focus, the inputMethodContext is deactivated. Thus when window gain focus again, the inputMethodContext must be activated.
767 mInputMethodContext.SetRestoreAfterFocusLost(true);
770 if(IsEditable() && mController->IsUserInteractionEnabled())
772 mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event
775 EmitKeyInputFocusSignal(true); // Calls back into the Control hence done last.
778 void TextField::OnKeyInputFocusLost()
780 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField:OnKeyInputFocusLost %p\n", mController.Get());
781 if(mInputMethodContext)
783 mInputMethodContext.StatusChangedSignal().Disconnect(this, &TextField::KeyboardStatusChanged);
784 // The text editing is finished. Therefore the inputMethodContext don't have restore activation.
785 mInputMethodContext.SetRestoreAfterFocusLost(false);
787 // Notify that the text editing finish.
788 mInputMethodContext.Deactivate();
790 mInputMethodContext.EventReceivedSignal().Disconnect(this, &TextField::OnInputMethodContextEvent);
793 mController->KeyboardFocusLostEvent();
795 EmitKeyInputFocusSignal(false); // Calls back into the Control hence done last.
798 bool TextField::OnAccessibilityActivated()
804 void TextField::OnTap(const TapGesture& gesture)
806 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::OnTap %p\n", mController.Get());
808 // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
810 padding = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
811 const Vector2& localPoint = gesture.GetLocalPoint();
812 mController->TapEvent(gesture.GetNumberOfTaps(), localPoint.x - padding.start, localPoint.y - padding.top);
813 mController->AnchorEvent(localPoint.x - padding.start, localPoint.y - padding.top);
815 Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get();
816 if(keyboardFocusManager)
818 keyboardFocusManager.SetCurrentFocusActor(Self());
823 void TextField::OnPan(const PanGesture& gesture)
825 mController->PanEvent(gesture.GetState(), gesture.GetDisplacement());
826 if(gesture.GetState() == GestureState::STARTED && !mController->IsScrollable(gesture.GetDisplacement()))
828 Dali::DevelActor::SetNeedGesturePropagation(Self(), true);
832 void TextField::OnLongPress(const LongPressGesture& gesture)
834 if(mInputMethodContext && IsEditable())
836 mInputMethodContext.Activate();
839 padding = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
840 const Vector2& localPoint = gesture.GetLocalPoint();
841 mController->LongPressEvent(gesture.GetState(), localPoint.x - padding.start, localPoint.y - padding.top);
846 bool TextField::OnKeyEvent(const KeyEvent& event)
848 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.GetKeyCode());
850 if(Dali::DALI_KEY_ESCAPE == event.GetKeyCode() && mController->ShouldClearFocusOnEscape())
852 // Make sure ClearKeyInputFocus when only key is up
853 if(event.GetState() == KeyEvent::UP)
855 Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get();
856 if(keyboardFocusManager)
858 keyboardFocusManager.ClearFocus();
860 ClearKeyInputFocus();
865 else if(Dali::DevelKey::DALI_KEY_RETURN == event.GetKeyCode() && KEY_RETURN_NAME == event.GetKeyName())
867 // Do nothing when enter is comming.
871 return mController->KeyEvent(event);
874 void TextField::RequestTextRelayout()
879 bool TextField::IsEditable() const
881 return mController->IsEditable();
884 void TextField::SetEditable(bool editable)
886 mController->SetEditable(editable);
887 if(mInputMethodContext && !editable)
889 mInputMethodContext.Deactivate();
893 void TextField::TextInserted(unsigned int position, unsigned int length, const std::string& content)
895 auto accessible = GetAccessibleObject();
896 if(DALI_LIKELY(accessible))
898 accessible->EmitTextInserted(position, length, content);
902 void TextField::TextDeleted(unsigned int position, unsigned int length, const std::string& content)
904 auto accessible = GetAccessibleObject();
905 if(DALI_LIKELY(accessible))
907 accessible->EmitTextDeleted(position, length, content);
911 void TextField::CursorPositionChanged(unsigned int oldPosition, unsigned int newPosition)
913 auto accessible = GetAccessibleObject();
914 if(DALI_LIKELY(accessible))
916 accessible->EmitTextCursorMoved(newPosition);
919 if((oldPosition != newPosition) && !mCursorPositionChanged)
921 mCursorPositionChanged = true;
922 mOldPosition = oldPosition;
926 void TextField::TextChanged(bool immediate)
928 if(immediate) // Emits TextChangedSignal immediately
930 EmitTextChangedSignal();
938 void TextField::EmitTextChangedSignal()
940 Dali::Toolkit::TextField handle(GetOwner());
941 mTextChangedSignal.Emit(handle);
942 mTextChanged = false;
945 void TextField::MaxLengthReached()
947 Dali::Toolkit::TextField handle(GetOwner());
948 mMaxLengthReachedSignal.Emit(handle);
951 void TextField::InputStyleChanged(Text::InputStyle::Mask inputStyleMask)
953 Dali::Toolkit::TextField handle(GetOwner());
954 mInputStyleChangedSignal.Emit(handle, ConvertInputStyle(inputStyleMask));
957 void TextField::AnchorClicked(const std::string& href)
959 Dali::Toolkit::TextField handle(GetOwner());
960 mAnchorClickedSignal.Emit(handle, href.c_str(), href.length());
963 void TextField::EmitCursorPositionChangedSignal()
965 Dali::Toolkit::TextField handle(GetOwner());
966 mCursorPositionChangedSignal.Emit(handle, mOldPosition);
967 mCursorPositionChanged = false;
970 void TextField::InputFiltered(Toolkit::InputFilter::Property::Type type)
972 Dali::Toolkit::TextField handle(GetOwner());
973 mInputFilteredSignal.Emit(handle, type);
976 void TextField::EmitSelectionChangedSignal()
978 Dali::Toolkit::TextField handle(GetOwner());
979 mSelectionChangedSignal.Emit(handle, mOldSelectionStart, mOldSelectionEnd);
980 mSelectionChanged = false;
983 void TextField::EmitSelectionClearedSignal()
985 Dali::Toolkit::TextField handle(GetOwner());
986 mSelectionClearedSignal.Emit(handle);
987 mSelectionCleared = false;
990 void TextField::EmitSelectionStartedSignal()
992 Dali::Toolkit::TextField handle(GetOwner());
993 mSelectionStartedSignal.Emit(handle);
994 mSelectionStarted = false;
997 void TextField::SelectionChanged(uint32_t oldStart, uint32_t oldEnd, uint32_t newStart, uint32_t newEnd)
999 if(((oldStart != newStart) || (oldEnd != newEnd)) && !mSelectionChanged)
1001 if(newStart == newEnd)
1003 mSelectionCleared = true;
1007 if(oldStart == oldEnd)
1009 mSelectionStarted = true;
1013 mSelectionChanged = true;
1014 mOldSelectionStart = oldStart;
1015 mOldSelectionEnd = oldEnd;
1017 if(mOldSelectionStart > mOldSelectionEnd)
1020 uint32_t temp = mOldSelectionStart;
1021 mOldSelectionStart = mOldSelectionEnd;
1022 mOldSelectionEnd = temp;
1027 void TextField::AddDecoration(Actor& actor, DecorationType type, bool needsClipping)
1033 mClippingDecorationActors.push_back(actor);
1036 // If the actor is a layer type, add it.
1037 if(type == DecorationType::ACTIVE_LAYER)
1039 AddLayer(mActiveLayer, actor);
1041 else if(type == DecorationType::CURSOR_LAYER)
1043 AddLayer(mCursorLayer, actor);
1048 void TextField::AddLayer(Actor& layer, Actor& actor)
1050 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1051 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1056 void TextField::GetControlBackgroundColor(Vector4& color) const
1058 Property::Value propValue = Self().GetProperty(Toolkit::Control::Property::BACKGROUND);
1059 Property::Map* resultMap = propValue.GetMap();
1061 Property::Value* colorValue = nullptr;
1062 if(resultMap && (colorValue = resultMap->Find(ColorVisual::Property::MIX_COLOR)))
1064 colorValue->Get(color);
1068 void TextField::OnSceneConnect(Dali::Actor actor)
1072 RenderText(static_cast<Text::Controller::UpdateTextType>(Text::Controller::MODEL_UPDATED | Text::Controller::DECORATOR_UPDATED));
1076 mHasBeenStaged = true;
1080 InputMethodContext::CallbackData TextField::OnInputMethodContextEvent(Dali::InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent)
1082 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::OnInputMethodContextEvent %p eventName %d\n", mController.Get(), inputMethodContextEvent.eventName);
1083 return mController->OnInputMethodContextEvent(inputMethodContext, inputMethodContextEvent);
1086 void TextField::GetHandleImagePropertyValue(Property::Value& value, Text::HandleType handleType, Text::HandleImageType handleImageType)
1091 map[PropertyHandler::IMAGE_MAP_FILENAME_STRING] = mDecorator->GetHandleImage(handleType, handleImageType);
1097 void TextField::EnableClipping()
1101 // Creates an extra control to be used as stencil buffer.
1102 mStencil = Control::New();
1103 mStencil.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1104 mStencil.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1105 mStencil.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN, true);
1107 // Creates a background visual. Even if the color is transparent it updates the stencil.
1108 mStencil.SetProperty(Toolkit::Control::Property::BACKGROUND,
1109 Property::Map().Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR).Add(ColorVisual::Property::MIX_COLOR, Color::TRANSPARENT));
1111 // Enable the clipping property.
1112 mStencil.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
1113 mStencil.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1115 Self().Add(mStencil);
1119 void TextField::KeyboardStatusChanged(bool keyboardShown)
1121 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown);
1123 // Just hide the grab handle when keyboard is hidden.
1126 mController->KeyboardFocusLostEvent();
1130 mController->KeyboardFocusGainEvent(); // Initially called by OnKeyInputFocusGained
1134 void TextField::OnSceneConnection(int depth)
1136 // Sets the depth to the visuals inside the text's decorator.
1137 mDecorator->SetTextDepth(depth);
1139 // The depth of the text renderer is set in the RenderText() called from OnRelayout().
1141 // Call the Control::OnSceneConnection() to set the depth of the background.
1142 Control::OnSceneConnection(depth);
1145 bool TextField::OnTouched(Actor actor, const TouchEvent& touch)
1150 void TextField::OnLayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
1152 mController->ChangedLayoutDirection();
1155 void TextField::OnIdleSignal()
1157 // Emits the change of input style signals.
1158 mController->ProcessInputStyleChangedSignals();
1160 // Set the pointer to null as the callback manager deletes the callback after execute it.
1161 mIdleCallback = NULL;
1164 TextField::TextField(ControlBehaviour additionalBehaviour)
1165 : Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT | additionalBehaviour)),
1166 mIdleCallback(NULL),
1167 mAlignmentOffset(0.f),
1168 mRenderingBackend(DEFAULT_RENDERING_BACKEND),
1169 mExceedPolicy(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP),
1170 mHasBeenStaged(false),
1171 mTextChanged(false),
1172 mCursorPositionChanged(false),
1173 mSelectionChanged(false),
1174 mSelectionCleared(false),
1176 mOldSelectionStart(0u),
1177 mOldSelectionEnd(0u),
1178 mSelectionStarted(false)
1182 TextField::~TextField()
1184 UnparentAndReset(mStencil);
1186 if((NULL != mIdleCallback) && Adaptor::IsAvailable())
1188 Adaptor::Get().RemoveIdle(mIdleCallback);
1192 Vector<Vector2> TextField::GetTextSize(const uint32_t startIndex, const uint32_t endIndex) const
1194 return mController->GetTextSize(startIndex, endIndex);
1197 Vector<Vector2> TextField::GetTextPosition(const uint32_t startIndex, const uint32_t endIndex) const
1199 return mController->GetTextPosition(startIndex, endIndex);
1202 Rect<float> TextField::GetLineBoundingRectangle(const uint32_t lineIndex) const
1204 return mController->GetLineBoundingRectangle(lineIndex);
1207 Rect<float> TextField::GetCharacterBoundingRectangle(const uint32_t charIndex) const
1209 return mController->GetCharacterBoundingRectangle(charIndex);
1212 int TextField::GetCharacterIndexAtPosition(float visualX, float visualY) const
1214 return mController->GetCharacterIndexAtPosition(visualX, visualY);
1217 Rect<> TextField::GetTextBoundingRectangle(uint32_t startIndex, uint32_t endIndex) const
1219 return mController->GetTextBoundingRectangle(startIndex, endIndex);
1222 void TextField::SetSpannedText(const Text::Spanned& spannedText)
1224 mController->SetSpannedText(spannedText);
1227 std::string TextField::TextFieldAccessible::GetName() const
1234 return GetWholeText();
1237 const std::vector<Toolkit::TextAnchor>& TextField::TextFieldAccessible::GetTextAnchors() const
1239 auto self = Toolkit::TextField::DownCast(Self());
1241 return Toolkit::GetImpl(self).mAnchorActors;
1244 Toolkit::Text::ControllerPtr TextField::TextFieldAccessible::GetTextController() const
1246 auto self = Toolkit::TextField::DownCast(Self());
1248 return Toolkit::GetImpl(self).GetTextController();
1251 std::uint32_t TextField::TextFieldAccessible::GetSubstituteCharacter() const
1253 auto self = Toolkit::TextField::DownCast(Self());
1254 auto hiddenInputSettings = self.GetProperty<Property::Map>(Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS);
1255 auto substChar = hiddenInputSettings.Find(Toolkit::HiddenInput::Property::SUBSTITUTE_CHARACTER);
1259 return static_cast<std::uint32_t>(substChar->Get<int>());
1262 return TextControlAccessible::GetSubstituteCharacter();
1265 bool TextField::TextFieldAccessible::IsHiddenInput() const
1267 auto self = Toolkit::TextField::DownCast(Self());
1268 auto hiddenInputSettings = self.GetProperty<Property::Map>(Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS);
1269 auto mode = hiddenInputSettings.Find(Toolkit::HiddenInput::Property::MODE);
1271 return (mode && (mode->Get<int>() != Toolkit::HiddenInput::Mode::HIDE_NONE));
1274 void TextField::TextFieldAccessible::RequestTextRelayout()
1276 auto self = Toolkit::TextField::DownCast(Self());
1277 auto& selfImpl = Toolkit::GetImpl(self);
1279 selfImpl.RequestTextRelayout();
1282 } // namespace Internal
1284 } // namespace Toolkit