2 * Copyright (c) 2020 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>
23 #include <dali/public-api/adaptor-framework/key.h>
24 #include <dali/public-api/common/dali-common.h>
25 #include <dali/devel-api/adaptor-framework/key-devel.h>
26 #include <dali/devel-api/adaptor-framework/window-devel.h>
27 #include <dali/devel-api/common/stage.h>
28 #include <dali/devel-api/object/property-helper-devel.h>
29 #include <dali/devel-api/actors/actor-devel.h>
30 #include <dali/public-api/object/type-registry-helper.h>
31 #include <dali/integration-api/debug.h>
34 #include <dali-toolkit/public-api/text/text-enumerations.h>
35 #include <dali-toolkit/public-api/visuals/color-visual-properties.h>
36 #include <dali-toolkit/devel-api/text/rendering-backend.h>
37 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
38 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
39 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
40 #include <dali-toolkit/public-api/visuals/visual-properties.h>
41 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
42 #include <dali-toolkit/internal/controls/text-controls/autofill-container-impl.h>
43 #include <dali-toolkit/internal/text/text-enumerations-impl.h>
44 #include <dali-toolkit/internal/text/rendering/text-backend.h>
45 #include <dali-toolkit/internal/text/text-effects-style.h>
46 #include <dali-toolkit/internal/text/text-font-style.h>
47 #include <dali-toolkit/internal/text/text-view.h>
48 #include <dali-toolkit/internal/styling/style-manager-impl.h>
49 #include <dali-toolkit/devel-api/controls/control-devel.h>
50 #include <dali/integration-api/adaptor-framework/adaptor.h>
52 using namespace Dali::Toolkit::Text;
63 namespace // unnamed namespace
66 #if defined(DEBUG_ENABLED)
67 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS");
70 const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::DevelText::DEFAULT_RENDERING_BACKEND;
71 } // unnamed namespace
78 return Toolkit::TextField::New();
81 // Setup properties, signals and actions using the type-registry.
82 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextField, Toolkit::Control, Create );
84 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "text", STRING, TEXT )
85 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholderText", STRING, PLACEHOLDER_TEXT )
86 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholderTextFocused", STRING, PLACEHOLDER_TEXT_FOCUSED )
87 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "fontFamily", STRING, FONT_FAMILY )
88 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "fontStyle", MAP, FONT_STYLE )
89 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "pointSize", FLOAT, POINT_SIZE )
90 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "maxLength", INTEGER, MAX_LENGTH )
91 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "exceedPolicy", INTEGER, EXCEED_POLICY )
92 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "horizontalAlignment", STRING, HORIZONTAL_ALIGNMENT )
93 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "verticalAlignment", STRING, VERTICAL_ALIGNMENT )
94 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "textColor", VECTOR4, TEXT_COLOR )
95 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholderTextColor", VECTOR4, PLACEHOLDER_TEXT_COLOR )
96 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "primaryCursorColor", VECTOR4, PRIMARY_CURSOR_COLOR )
97 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "secondaryCursorColor", VECTOR4, SECONDARY_CURSOR_COLOR )
98 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enableCursorBlink", BOOLEAN, ENABLE_CURSOR_BLINK )
99 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursorBlinkInterval", FLOAT, CURSOR_BLINK_INTERVAL )
100 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursorBlinkDuration", FLOAT, CURSOR_BLINK_DURATION )
101 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursorWidth", INTEGER, CURSOR_WIDTH )
102 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "grabHandleImage", STRING, GRAB_HANDLE_IMAGE )
103 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "grabHandlePressedImage", STRING, GRAB_HANDLE_PRESSED_IMAGE )
104 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "scrollThreshold", FLOAT, SCROLL_THRESHOLD )
105 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "scrollSpeed", FLOAT, SCROLL_SPEED )
106 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandleImageLeft", MAP, SELECTION_HANDLE_IMAGE_LEFT )
107 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandleImageRight", MAP, SELECTION_HANDLE_IMAGE_RIGHT )
108 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandlePressedImageLeft", MAP, SELECTION_HANDLE_PRESSED_IMAGE_LEFT )
109 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandlePressedImageRight", MAP, SELECTION_HANDLE_PRESSED_IMAGE_RIGHT )
110 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandleMarkerImageLeft", MAP, SELECTION_HANDLE_MARKER_IMAGE_LEFT )
111 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandleMarkerImageRight", MAP, SELECTION_HANDLE_MARKER_IMAGE_RIGHT )
112 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHighlightColor", VECTOR4, SELECTION_HIGHLIGHT_COLOR )
113 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "decorationBoundingBox", RECTANGLE, DECORATION_BOUNDING_BOX )
114 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputMethodSettings", MAP, INPUT_METHOD_SETTINGS )
115 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputColor", VECTOR4, INPUT_COLOR )
116 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enableMarkup", BOOLEAN, ENABLE_MARKUP )
117 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputFontFamily", STRING, INPUT_FONT_FAMILY )
118 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputFontStyle", MAP, INPUT_FONT_STYLE )
119 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputPointSize", FLOAT, INPUT_POINT_SIZE )
120 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "underline", MAP, UNDERLINE )
121 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputUnderline", MAP, INPUT_UNDERLINE )
122 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadow", MAP, SHADOW )
123 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputShadow", MAP, INPUT_SHADOW )
124 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "emboss", MAP, EMBOSS )
125 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputEmboss", MAP, INPUT_EMBOSS )
126 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "outline", MAP, OUTLINE )
127 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputOutline", MAP, INPUT_OUTLINE )
128 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "hiddenInputSettings", MAP, HIDDEN_INPUT_SETTINGS )
129 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "pixelSize", FLOAT, PIXEL_SIZE )
130 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enableSelection", BOOLEAN, ENABLE_SELECTION )
131 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholder", MAP, PLACEHOLDER )
132 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "ellipsis", BOOLEAN, ELLIPSIS )
133 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableShiftSelection", BOOLEAN, ENABLE_SHIFT_SELECTION )
134 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableGrabHandle", BOOLEAN, ENABLE_GRAB_HANDLE )
135 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "matchSystemLanguageDirection", BOOLEAN, MATCH_SYSTEM_LANGUAGE_DIRECTION )
136 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableGrabHandlePopup", BOOLEAN, ENABLE_GRAB_HANDLE_POPUP )
137 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "textBackground", VECTOR4, BACKGROUND )
138 DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextField, "selectedText", STRING, SELECTED_TEXT )
139 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "renderingBackend", INTEGER, RENDERING_BACKEND )
140 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "selectedTextStart", INTEGER, SELECTED_TEXT_START )
141 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "selectedTextEnd", INTEGER, SELECTED_TEXT_END )
142 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableEditing", BOOLEAN, ENABLE_EDITING )
143 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "fontSizeScale", FLOAT, FONT_SIZE_SCALE )
145 DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED )
146 DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED )
147 DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED )
149 DALI_TYPE_REGISTRATION_END()
151 const char * const IMAGE_MAP_FILENAME_STRING = "filename";
153 /// Retrieves a filename from a value that is a Property::Map
154 std::string GetImageFileNameFromPropertyValue( const Property::Value& value )
156 std::string filename;
157 const Property::Map* map = value.GetMap();
160 const Property::Value* filenameValue = map->Find( IMAGE_MAP_FILENAME_STRING );
163 filenameValue->Get( filename );
171 Toolkit::TextField TextField::New()
173 // Create the implementation, temporarily owned by this handle on stack
174 IntrusivePtr< TextField > impl = new TextField();
176 // Pass ownership to CustomActor handle
177 Toolkit::TextField handle( *impl );
179 // Second-phase init of the implementation
180 // This can only be done after the CustomActor connection has been made...
186 void TextField::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
188 Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
190 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField SetProperty\n");
194 TextField& impl( GetImpl( textField ) );
195 DALI_ASSERT_DEBUG( impl.mController && "No text contoller" );
196 DALI_ASSERT_DEBUG( impl.mDecorator && "No text decorator" );
200 case Toolkit::DevelTextField::Property::RENDERING_BACKEND:
202 int backend = value.Get< int >();
203 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p RENDERING_BACKEND %d\n", impl.mController.Get(), backend );
205 #ifndef ENABLE_VECTOR_BASED_TEXT_RENDERING
206 if( DevelText::RENDERING_VECTOR_BASED == backend )
208 backend = TextAbstraction::BITMAP_GLYPH; // Fallback to bitmap-based rendering
211 if( impl.mRenderingBackend != backend )
213 impl.mRenderingBackend = backend;
214 impl.mRenderer.Reset();
216 // When using the vector-based rendering, the size of the GLyphs are different
217 TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == impl.mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
218 impl.mController->SetGlyphType( glyphType );
222 case Toolkit::TextField::Property::TEXT:
224 const std::string& text = value.Get< std::string >();
225 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p TEXT %s\n", impl.mController.Get(), text.c_str() );
227 impl.mController->SetText( text );
230 case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
232 const std::string& text = value.Get< std::string >();
233 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str() );
235 impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
238 case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED:
240 const std::string& text = value.Get< std::string >();
241 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_FOCUSED %s\n", impl.mController.Get(), text.c_str() );
243 impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text );
246 case Toolkit::TextField::Property::FONT_FAMILY:
248 const std::string& fontFamily = value.Get< std::string >();
249 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
250 impl.mController->SetDefaultFontFamily( fontFamily );
253 case Toolkit::TextField::Property::FONT_STYLE:
255 SetFontStyleProperty( impl.mController, value, Text::FontStyle::DEFAULT );
258 case Toolkit::TextField::Property::POINT_SIZE:
260 const float pointSize = value.Get< float >();
261 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p POINT_SIZE %f\n", impl.mController.Get(), pointSize );
263 if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ), pointSize ) )
265 impl.mController->SetDefaultFontSize( pointSize, Text::Controller::POINT_SIZE );
269 case Toolkit::TextField::Property::MAX_LENGTH:
271 const int max = value.Get< int >();
272 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p MAX_LENGTH %d\n", impl.mController.Get(), max );
274 impl.mController->SetMaximumNumberOfCharacters( max );
277 case Toolkit::TextField::Property::EXCEED_POLICY:
279 impl.mExceedPolicy = value.Get<int>();
281 if( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == impl.mExceedPolicy )
283 impl.EnableClipping();
287 UnparentAndReset( impl.mStencil );
289 impl.RequestTextRelayout();
292 case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
294 Text::HorizontalAlignment::Type alignment( static_cast< Text::HorizontalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set
295 if( GetHorizontalAlignmentEnumeration( value, alignment ) )
297 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p HORIZONTAL_ALIGNMENT %d\n", impl.mController.Get(), alignment );
298 impl.mController->SetHorizontalAlignment( alignment );
302 case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
304 Toolkit::Text::VerticalAlignment::Type alignment( static_cast< Text::VerticalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set
305 if( GetVerticalAlignmentEnumeration( value, alignment ) )
307 impl.mController->SetVerticalAlignment( alignment );
308 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p VERTICAL_ALIGNMENT %d\n", impl.mController.Get(), alignment );
312 case Toolkit::TextField::Property::TEXT_COLOR:
314 const Vector4& textColor = value.Get< Vector4 >();
315 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a );
317 if( impl.mController->GetDefaultColor() != textColor )
319 impl.mController->SetDefaultColor( textColor );
320 impl.mController->SetInputColor( textColor );
321 impl.mRenderer.Reset();
325 case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR:
327 const Vector4& textColor = value.Get< Vector4 >();
328 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a );
330 if( impl.mController->GetPlaceholderTextColor() != textColor )
332 impl.mController->SetPlaceholderTextColor( textColor );
333 impl.mRenderer.Reset();
337 case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
339 const Vector4& color = value.Get< Vector4 >();
340 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
342 impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color );
343 impl.RequestTextRelayout();
346 case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
348 const Vector4& color = value.Get< Vector4 >();
349 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SECONDARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
351 impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color );
352 impl.RequestTextRelayout();
355 case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
357 const bool enable = value.Get< bool >();
358 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable );
360 impl.mController->SetEnableCursorBlink( enable );
361 impl.RequestTextRelayout();
364 case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
366 const float interval = value.Get< float >();
367 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval );
369 impl.mDecorator->SetCursorBlinkInterval( interval );
372 case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
374 const float duration = value.Get< float >();
375 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration );
377 impl.mDecorator->SetCursorBlinkDuration( duration );
380 case Toolkit::TextField::Property::CURSOR_WIDTH:
382 const int width = value.Get< int >();
383 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_WIDTH %d\n", impl.mController.Get(), width );
385 impl.mDecorator->SetCursorWidth( width );
386 impl.mController->GetLayoutEngine().SetCursorWidth( width );
389 case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
391 const std::string imageFileName = value.Get< std::string >();
392 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str() );
394 if( imageFileName.size() )
396 impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED, imageFileName );
397 impl.RequestTextRelayout();
401 case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
403 const std::string imageFileName = value.Get< std::string >();
404 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str() );
406 if( imageFileName.size() )
408 impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED, imageFileName );
409 impl.RequestTextRelayout();
413 case Toolkit::TextField::Property::SCROLL_THRESHOLD:
415 const float threshold = value.Get< float >();
416 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold );
418 impl.mDecorator->SetScrollThreshold( threshold );
421 case Toolkit::TextField::Property::SCROLL_SPEED:
423 const float speed = value.Get< float >();
424 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p SCROLL_SPEED %f\n", impl.mController.Get(), speed );
426 impl.mDecorator->SetScrollSpeed( speed );
429 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
431 const std::string filename = GetImageFileNameFromPropertyValue( value );
433 if( filename.size() )
435 impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, filename );
436 impl.RequestTextRelayout();
440 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
442 const std::string filename = GetImageFileNameFromPropertyValue( value );
444 if( filename.size() )
446 impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, filename );
447 impl.RequestTextRelayout();
451 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
453 const std::string filename = GetImageFileNameFromPropertyValue( value );
455 if( filename.size() )
457 impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, filename );
458 impl.RequestTextRelayout();
462 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
464 const std::string filename = GetImageFileNameFromPropertyValue( value );
466 if( filename.size() )
468 impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, filename );
469 impl.RequestTextRelayout();
473 case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
475 const std::string filename = GetImageFileNameFromPropertyValue( value );
477 if( filename.size() )
479 impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, filename );
480 impl.RequestTextRelayout();
484 case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
486 const std::string filename = GetImageFileNameFromPropertyValue( value );
488 if( filename.size() )
490 impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, filename );
491 impl.RequestTextRelayout();
495 case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
497 const Vector4 color = value.Get< Vector4 >();
498 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SELECTION_HIGHLIGHT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
500 impl.mDecorator->SetHighlightColor( color );
501 impl.RequestTextRelayout();
504 case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
506 const Rect<int> box = value.Get< Rect<int> >();
507 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p DECORATION_BOUNDING_BOX %d,%d %dx%d\n", impl.mController.Get(), box.x, box.y, box.width, box.height );
509 impl.mDecorator->SetBoundingBox( box );
510 impl.RequestTextRelayout();
513 case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS:
515 const Property::Map* map = value.GetMap();
518 impl.mInputMethodOptions.ApplyProperty( *map );
520 impl.mController->SetInputModePassword( impl.mInputMethodOptions.IsPassword() );
522 Toolkit::Control control = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl();
523 if (control == textField)
525 impl.mInputMethodContext.ApplyOptions( impl.mInputMethodOptions );
529 case Toolkit::TextField::Property::INPUT_COLOR:
531 const Vector4 inputColor = value.Get< Vector4 >();
532 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), inputColor.r, inputColor.g, inputColor.b, inputColor.a );
534 impl.mController->SetInputColor( inputColor );
537 case Toolkit::TextField::Property::ENABLE_MARKUP:
539 const bool enableMarkup = value.Get<bool>();
540 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup );
542 impl.mController->SetMarkupProcessorEnabled( enableMarkup );
545 case Toolkit::TextField::Property::INPUT_FONT_FAMILY:
547 const std::string& fontFamily = value.Get< std::string >();
548 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
549 impl.mController->SetInputFontFamily( fontFamily );
552 case Toolkit::TextField::Property::INPUT_FONT_STYLE:
554 SetFontStyleProperty( impl.mController, value, Text::FontStyle::INPUT );
557 case Toolkit::TextField::Property::INPUT_POINT_SIZE:
559 const float pointSize = value.Get< float >();
560 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize );
561 impl.mController->SetInputFontPointSize( pointSize );
564 case Toolkit::TextField::Property::UNDERLINE:
566 const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
569 impl.mRenderer.Reset();
573 case Toolkit::TextField::Property::INPUT_UNDERLINE:
575 const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
578 impl.mRenderer.Reset();
582 case Toolkit::TextField::Property::SHADOW:
584 const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
587 impl.mRenderer.Reset();
591 case Toolkit::TextField::Property::INPUT_SHADOW:
593 const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT );
596 impl.mRenderer.Reset();
600 case Toolkit::TextField::Property::EMBOSS:
602 const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
605 impl.mRenderer.Reset();
609 case Toolkit::TextField::Property::INPUT_EMBOSS:
611 const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT );
614 impl.mRenderer.Reset();
618 case Toolkit::TextField::Property::OUTLINE:
620 const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
623 impl.mRenderer.Reset();
627 case Toolkit::TextField::Property::INPUT_OUTLINE:
629 const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
632 impl.mRenderer.Reset();
636 case Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS:
638 const Property::Map* map = value.GetMap();
641 impl.mController->SetHiddenInputOption(*map);
645 case Toolkit::TextField::Property::PIXEL_SIZE:
647 const float pixelSize = value.Get< float >();
648 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize );
650 if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ), pixelSize ) )
652 impl.mController->SetDefaultFontSize( pixelSize, Text::Controller::PIXEL_SIZE );
656 case Toolkit::TextField::Property::ENABLE_SELECTION:
658 const bool enableSelection = value.Get< bool >();
659 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection );
660 impl.mController->SetSelectionEnabled( enableSelection );
663 case Toolkit::TextField::Property::PLACEHOLDER:
665 const Property::Map* map = value.GetMap();
668 impl.mController->SetPlaceholderProperty( *map );
672 case Toolkit::TextField::Property::ELLIPSIS:
674 const bool ellipsis = value.Get<bool>();
675 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis );
677 impl.mController->SetTextElideEnabled( ellipsis );
680 case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION:
682 const bool shiftSelection = value.Get<bool>();
683 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection );
685 impl.mController->SetShiftSelectionEnabled( shiftSelection );
688 case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE:
690 const bool grabHandleEnabled = value.Get<bool>();
691 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled );
693 impl.mController->SetGrabHandleEnabled( grabHandleEnabled );
696 case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
698 impl.mController->SetMatchSystemLanguageDirection(value.Get< bool >());
701 case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP:
703 const bool grabHandlePopupEnabled = value.Get<bool>();
704 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE_POPUP %d\n", impl.mController.Get(), grabHandlePopupEnabled);
706 impl.mController->SetGrabHandlePopupEnabled(grabHandlePopupEnabled);
709 case Toolkit::DevelTextField::Property::BACKGROUND:
711 const Vector4 backgroundColor = value.Get< Vector4 >();
712 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p BACKGROUND %f,%f,%f,%f\n", impl.mController.Get(), backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a );
714 impl.mController->SetBackgroundEnabled( true );
715 impl.mController->SetBackgroundColor( backgroundColor );
718 case Toolkit::DevelTextField::Property::SELECTED_TEXT_START:
720 uint32_t start = static_cast<uint32_t>(value.Get< int >());
721 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start );
722 impl.SetTextSelectionRange( &start, nullptr );
725 case Toolkit::DevelTextField::Property::SELECTED_TEXT_END:
727 uint32_t end = static_cast<uint32_t>(value.Get< int >());
728 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end );
729 impl.SetTextSelectionRange( nullptr, &end );
732 case Toolkit::DevelTextField::Property::ENABLE_EDITING:
734 const bool editable = value.Get< bool >();
735 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_EDITING %d\n", impl.mController.Get(), editable );
736 impl.SetEditable( editable );
739 case Toolkit::DevelTextField::Property::FONT_SIZE_SCALE:
741 const float scale = value.Get< float >();
742 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_SIZE_SCALE %f\n", impl.mController.Get(), scale );
744 if( !Equals( impl.mController->GetFontSizeScale(), scale ) )
746 impl.mController->SetFontSizeScale( scale );
754 Property::Value TextField::GetProperty( BaseObject* object, Property::Index index )
756 Property::Value value;
758 Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
762 TextField& impl( GetImpl( textField ) );
763 DALI_ASSERT_DEBUG( impl.mController && "No text contoller" );
764 DALI_ASSERT_DEBUG( impl.mDecorator && "No text decorator" );
768 case Toolkit::DevelTextField::Property::RENDERING_BACKEND:
770 value = impl.mRenderingBackend;
773 case Toolkit::TextField::Property::TEXT:
776 impl.mController->GetText( text );
777 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p returning text: %s\n", impl.mController.Get(), text.c_str() );
781 case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
784 impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
788 case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED:
791 impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text );
795 case Toolkit::TextField::Property::FONT_FAMILY:
797 value = impl.mController->GetDefaultFontFamily();
800 case Toolkit::TextField::Property::FONT_STYLE:
802 GetFontStyleProperty( impl.mController, value, Text::FontStyle::DEFAULT );
805 case Toolkit::TextField::Property::POINT_SIZE:
807 value = impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE );
810 case Toolkit::TextField::Property::MAX_LENGTH:
812 value = impl.mController->GetMaximumNumberOfCharacters();
815 case Toolkit::TextField::Property::EXCEED_POLICY:
817 value = impl.mExceedPolicy;
820 case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
822 const char* name = Text::GetHorizontalAlignmentString( impl.mController->GetHorizontalAlignment() );
826 value = std::string( name );
830 case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
832 const char* name = Text::GetVerticalAlignmentString( impl.mController->GetVerticalAlignment() );
836 value = std::string( name );
840 case Toolkit::TextField::Property::TEXT_COLOR:
842 value = impl.mController->GetDefaultColor();
845 case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR:
847 value = impl.mController->GetPlaceholderTextColor();
850 case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
852 value = impl.mDecorator->GetColor( PRIMARY_CURSOR );
855 case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
857 value = impl.mDecorator->GetColor( SECONDARY_CURSOR );
860 case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
862 value = impl.mController->GetEnableCursorBlink();
865 case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
867 value = impl.mDecorator->GetCursorBlinkInterval();
870 case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
872 value = impl.mDecorator->GetCursorBlinkDuration();
875 case Toolkit::TextField::Property::CURSOR_WIDTH:
877 value = impl.mDecorator->GetCursorWidth();
880 case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
882 value = impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED );
885 case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
887 value = impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED );
890 case Toolkit::TextField::Property::SCROLL_THRESHOLD:
892 value = impl.mDecorator->GetScrollThreshold();
895 case Toolkit::TextField::Property::SCROLL_SPEED:
897 value = impl.mDecorator->GetScrollSpeed();
900 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
902 impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED );
905 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
907 impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED ) ;
910 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
912 impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED );
915 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
917 impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED );
920 case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
922 impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED );
925 case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
927 impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED );
930 case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
932 value = impl.mDecorator->GetHighlightColor();
935 case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
937 Rect<int> boundingBox;
938 impl.mDecorator->GetBoundingBox( boundingBox );
942 case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS:
945 impl.mInputMethodOptions.RetrieveProperty( map );
949 case Toolkit::TextField::Property::INPUT_COLOR:
951 value = impl.mController->GetInputColor();
954 case Toolkit::TextField::Property::ENABLE_MARKUP:
956 value = impl.mController->IsMarkupProcessorEnabled();
959 case Toolkit::TextField::Property::INPUT_FONT_FAMILY:
961 value = impl.mController->GetInputFontFamily();
964 case Toolkit::TextField::Property::INPUT_FONT_STYLE:
966 GetFontStyleProperty( impl.mController, value, Text::FontStyle::INPUT );
969 case Toolkit::TextField::Property::INPUT_POINT_SIZE:
971 value = impl.mController->GetInputFontPointSize();
974 case Toolkit::TextField::Property::UNDERLINE:
976 GetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
979 case Toolkit::TextField::Property::INPUT_UNDERLINE:
981 GetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
984 case Toolkit::TextField::Property::SHADOW:
986 GetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
989 case Toolkit::TextField::Property::INPUT_SHADOW:
991 GetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT );
994 case Toolkit::TextField::Property::EMBOSS:
996 GetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
999 case Toolkit::TextField::Property::INPUT_EMBOSS:
1001 GetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT );
1004 case Toolkit::TextField::Property::OUTLINE:
1006 GetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
1009 case Toolkit::TextField::Property::INPUT_OUTLINE:
1011 GetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
1014 case Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS:
1017 impl.mController->GetHiddenInputOption(map);
1021 case Toolkit::TextField::Property::PIXEL_SIZE:
1023 value = impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE );
1026 case Toolkit::TextField::Property::ENABLE_SELECTION:
1028 value = impl.mController->IsSelectionEnabled();
1031 case Toolkit::TextField::Property::PLACEHOLDER:
1034 impl.mController->GetPlaceholderProperty( map );
1038 case Toolkit::TextField::Property::ELLIPSIS:
1040 value = impl.mController->IsTextElideEnabled();
1043 case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION:
1045 value = impl.mController->IsShiftSelectionEnabled();
1048 case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE:
1050 value = impl.mController->IsGrabHandleEnabled();
1053 case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
1055 value = impl.mController->IsMatchSystemLanguageDirection();
1058 case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP:
1060 value = impl.mController->IsGrabHandlePopupEnabled();
1063 case Toolkit::DevelTextField::Property::BACKGROUND:
1065 value = impl.mController->GetBackgroundColor();
1068 case Toolkit::DevelTextField::Property::SELECTED_TEXT:
1070 value = impl.mController->GetSelectedText( );
1073 case Toolkit::DevelTextField::Property::SELECTED_TEXT_START:
1075 Uint32Pair range = impl.GetTextSelectionRange( );
1076 value = static_cast<int>(range.first);
1079 case Toolkit::DevelTextField::Property::SELECTED_TEXT_END:
1081 Uint32Pair range = impl.GetTextSelectionRange( );
1082 value = static_cast<int>(range.second);
1085 case Toolkit::DevelTextField::Property::ENABLE_EDITING:
1087 value = impl.IsEditable();
1090 case Toolkit::DevelTextField::Property::FONT_SIZE_SCALE:
1092 value = impl.mController->GetFontSizeScale();
1101 void TextField::SelectWholeText()
1103 if( mController && mController->IsShowingRealText() )
1105 mController->SelectWholeText();
1110 void TextField::SelectNone()
1112 if( mController && mController->IsShowingRealText() )
1114 mController->SelectNone();
1118 string TextField::GetSelectedText() const
1120 string selectedText = "";
1121 if( mController && mController->IsShowingRealText() )
1123 selectedText = mController->GetSelectedText( );
1125 return selectedText;
1128 void TextField::SetTextSelectionRange(const uint32_t *start, const uint32_t *end)
1130 if( mController && mController->IsShowingRealText() )
1132 mController->SetTextSelectionRange( start, end );
1137 Uint32Pair TextField::GetTextSelectionRange() const
1140 if( mController && mController->IsShowingRealText() )
1142 range = mController->GetTextSelectionRange();
1148 InputMethodContext TextField::GetInputMethodContext()
1150 return mInputMethodContext;
1153 bool TextField::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
1155 Dali::BaseHandle handle( object );
1157 bool connected( true );
1158 Toolkit::TextField field = Toolkit::TextField::DownCast( handle );
1160 if( 0 == strcmp( signalName.c_str(), SIGNAL_TEXT_CHANGED ) )
1162 field.TextChangedSignal().Connect( tracker, functor );
1164 else if( 0 == strcmp( signalName.c_str(), SIGNAL_MAX_LENGTH_REACHED ) )
1166 field.MaxLengthReachedSignal().Connect( tracker, functor );
1168 else if( 0 == strcmp( signalName.c_str(), SIGNAL_INPUT_STYLE_CHANGED ) )
1170 field.InputStyleChangedSignal().Connect( tracker, functor );
1174 // signalName does not match any signal
1181 Toolkit::TextField::TextChangedSignalType& TextField::TextChangedSignal()
1183 return mTextChangedSignal;
1186 Toolkit::TextField::MaxLengthReachedSignalType& TextField::MaxLengthReachedSignal()
1188 return mMaxLengthReachedSignal;
1191 Toolkit::TextField::InputStyleChangedSignalType& TextField::InputStyleChangedSignal()
1193 return mInputStyleChangedSignal;
1196 void TextField::OnInitialize()
1198 Actor self = Self();
1200 mController = Text::Controller::New( this, this ,this);
1202 // When using the vector-based rendering, the size of the GLyphs are different
1203 TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
1204 mController->SetGlyphType( glyphType );
1206 mDecorator = Text::Decorator::New( *mController,
1209 mInputMethodContext = InputMethodContext::New( self );
1211 mController->GetLayoutEngine().SetLayout( Layout::Engine::SINGLE_LINE_BOX );
1213 // Enables the text input.
1214 mController->EnableTextInput( mDecorator, mInputMethodContext );
1216 // Enables the horizontal scrolling after the text input has been enabled.
1217 mController->SetHorizontalScrollEnabled( true );
1219 // Disables the vertical scrolling.
1220 mController->SetVerticalScrollEnabled( false );
1222 // Disable the smooth handle panning.
1223 mController->SetSmoothHandlePanEnabled( false );
1225 mController->SetNoTextDoubleTapAction( Controller::NoTextTap::HIGHLIGHT );
1226 mController->SetNoTextLongPressAction( Controller::NoTextTap::HIGHLIGHT );
1228 // Sets layoutDirection value
1229 Dali::Stage stage = Dali::Stage::GetCurrent();
1230 Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( stage.GetRootLayer().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
1231 mController->SetLayoutDirection( layoutDirection );
1233 // Forward input events to controller
1234 EnableGestureDetection( static_cast<GestureType::Value>( GestureType::TAP | GestureType::PAN | GestureType::LONG_PRESS ) );
1235 GetTapGestureDetector().SetMaximumTapsRequired( 2 );
1237 self.TouchedSignal().Connect( this, &TextField::OnTouched );
1239 // Set BoundingBox to stage size if not already set.
1240 Rect<int> boundingBox;
1241 mDecorator->GetBoundingBox( boundingBox );
1243 if( boundingBox.IsEmpty() )
1245 Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
1246 mDecorator->SetBoundingBox( Rect<int>( 0.0f, 0.0f, stageSize.width, stageSize.height ) );
1249 // Flip vertically the 'left' selection handle
1250 mDecorator->FlipHandleVertically( LEFT_SELECTION_HANDLE, true );
1252 // Fill-parent area by default
1253 self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
1254 self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
1255 self.OnSceneSignal().Connect( this, &TextField::OnSceneConnect );
1257 //Enable highightability
1258 self.SetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true );
1260 DevelControl::SetInputMethodContext( *this, mInputMethodContext );
1262 if( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy )
1267 DevelControl::SetAccessibilityConstructor( self, []( Dali::Actor actor ) {
1268 return std::unique_ptr< Dali::Accessibility::Accessible >(
1269 new AccessibleImpl( actor, Dali::Accessibility::Role::ENTRY ) );
1273 void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
1275 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange\n");
1279 case StyleChange::DEFAULT_FONT_CHANGE:
1281 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n");
1282 const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily();
1283 // Property system did not set the font so should update it.
1284 mController->UpdateAfterFontChange( newFont );
1289 case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
1291 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
1295 case StyleChange::THEME_CHANGE:
1297 // Nothing to do, let control base class handle this
1302 // Up call to Control
1303 Control::OnStyleChange( styleManager, change );
1306 Vector3 TextField::GetNaturalSize()
1309 padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1311 Vector3 naturalSize = mController->GetNaturalSize();
1312 naturalSize.width += ( padding.start + padding.end );
1313 naturalSize.height += ( padding.top + padding.bottom );
1318 float TextField::GetHeightForWidth( float width )
1321 padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1322 return mController->GetHeightForWidth( width ) + padding.top + padding.bottom;
1325 void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
1327 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField OnRelayout\n");
1329 Actor self = Self();
1332 padding = self.GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1334 Vector2 contentSize( size.x - ( padding.start + padding.end ), size.y - ( padding.top + padding.bottom ) );
1336 // Support Right-To-Left of padding
1337 Dali::LayoutDirection::Type layoutDirection;
1338 if( mController->IsMatchSystemLanguageDirection() )
1340 layoutDirection = static_cast<Dali::LayoutDirection::Type>( DevelWindow::Get( self ).GetRootLayer().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
1344 layoutDirection = static_cast<Dali::LayoutDirection::Type>( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
1346 if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
1348 std::swap( padding.start, padding.end );
1353 mStencil.SetProperty( Actor::Property::POSITION, Vector2( padding.start, padding.top ));
1357 mActiveLayer.SetProperty( Actor::Property::POSITION, Vector2( padding.start, padding.top ));
1360 const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize, layoutDirection );
1362 if( ( Text::Controller::NONE_UPDATED != updateTextType ) ||
1365 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnRelayout %p Displaying new contents\n", mController.Get() );
1368 ( Text::Controller::NONE_UPDATED != ( Text::Controller::DECORATOR_UPDATED & updateTextType ) ) )
1370 mDecorator->Relayout( size );
1375 mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
1378 RenderText( updateTextType );
1382 // The text-field emits signals when the input style changes. These changes of style are
1383 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1384 // can't be emitted during the size negotiation as the callbacks may update the UI.
1385 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1386 if( !mController->IsInputStyleChangedSignalsQueueEmpty() )
1388 if( Adaptor::IsAvailable() )
1390 Adaptor& adaptor = Adaptor::Get();
1392 if( NULL == mIdleCallback )
1394 // @note: The callback manager takes the ownership of the callback object.
1395 mIdleCallback = MakeCallback( this, &TextField::OnIdleSignal );
1396 adaptor.AddIdle( mIdleCallback, false );
1402 Text::ControllerPtr TextField::getController() { return mController; }
1404 void TextField::RenderText( Text::Controller::UpdateTextType updateTextType )
1406 Actor renderableActor;
1408 if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
1412 Dali::Toolkit::TextField handle = Dali::Toolkit::TextField( GetOwner() );
1414 renderableActor = mRenderer->Render( mController->GetView(),
1416 Property::INVALID_INDEX, // Animatable property not supported
1418 DepthIndex::CONTENT );
1421 if( renderableActor != mRenderableActor )
1423 UnparentAndReset( mBackgroundActor );
1424 UnparentAndReset( mRenderableActor );
1425 mRenderableActor = renderableActor;
1427 if ( mRenderableActor )
1429 mBackgroundActor = mController->CreateBackgroundActor();
1434 if( mRenderableActor )
1436 const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition();
1438 float renderableActorPositionX, renderableActorPositionY;
1442 renderableActorPositionX = scrollOffset.x + mAlignmentOffset;
1443 renderableActorPositionY = scrollOffset.y;
1448 padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1450 // Support Right-To-Left of padding
1451 Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( Self().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
1452 if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
1454 std::swap( padding.start, padding.end );
1457 renderableActorPositionX = scrollOffset.x + mAlignmentOffset + padding.start;
1458 renderableActorPositionY = scrollOffset.y + padding.top;
1461 mRenderableActor.SetProperty( Actor::Property::POSITION, Vector2( renderableActorPositionX, renderableActorPositionY ));
1463 // Make sure the actors are parented correctly with/without clipping
1464 Actor self = mStencil ? mStencil : Self();
1466 Actor highlightActor;
1468 for( std::vector<Actor>::iterator it = mClippingDecorationActors.begin(),
1469 endIt = mClippingDecorationActors.end();
1474 it->LowerToBottom();
1476 if ( it->GetProperty< std::string >( Dali::Actor::Property::NAME ) == "HighlightActor" )
1478 highlightActor = *it;
1481 mClippingDecorationActors.clear();
1483 self.Add( mRenderableActor );
1485 if ( mBackgroundActor )
1487 if ( mDecorator && mDecorator->IsHighlightVisible() )
1489 self.Add( mBackgroundActor );
1490 mBackgroundActor.SetProperty( Actor::Property::POSITION, Vector2( renderableActorPositionX, renderableActorPositionY) ); // In text field's coords.
1491 mBackgroundActor.LowerBelow( highlightActor );
1495 mRenderableActor.Add( mBackgroundActor );
1496 mBackgroundActor.SetProperty( Actor::Property::POSITION, Vector2( 0.0f, 0.0f ) ); // In renderable actor's coords.
1497 mBackgroundActor.LowerToBottom();
1503 void TextField::OnKeyInputFocusGained()
1505 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() );
1506 if( mInputMethodContext && IsEditable() )
1508 mInputMethodContext.ApplyOptions( mInputMethodOptions );
1510 mInputMethodContext.StatusChangedSignal().Connect( this, &TextField::KeyboardStatusChanged );
1512 mInputMethodContext.EventReceivedSignal().Connect( this, &TextField::OnInputMethodContextEvent );
1514 // Notify that the text editing start.
1515 mInputMethodContext.Activate();
1517 // When window gain lost focus, the inputMethodContext is deactivated. Thus when window gain focus again, the inputMethodContext must be activated.
1518 mInputMethodContext.SetRestoreAfterFocusLost( true );
1521 ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
1524 notifier.ContentSelectedSignal().Connect( this, &TextField::OnClipboardTextSelected );
1527 Toolkit::Control control = Toolkit::Control::DownCast( Self() );
1528 Internal::Control& controlImpl = GetImplementation( control );
1529 Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
1530 bool enableAutofill = controlDataImpl.IsAutofillEnabled();
1531 if( enableAutofill )
1533 Toolkit::AutofillContainer container = controlDataImpl.GetAutofillContainer();
1534 container.SetFocusedControl( control );
1536 Internal::AutofillContainer& containerImpl = GetImpl( container );
1537 Dali::AutofillGroup containerGroup = containerImpl.GetAutofillGroup();
1538 if( containerGroup != nullptr )
1540 containerGroup.RequestAuthentication();
1544 mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event
1546 EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
1549 void TextField::OnKeyInputFocusLost()
1551 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField:OnKeyInputFocusLost %p\n", mController.Get() );
1552 if ( mInputMethodContext )
1554 mInputMethodContext.StatusChangedSignal().Disconnect( this, &TextField::KeyboardStatusChanged );
1555 // The text editing is finished. Therefore the inputMethodContext don't have restore activation.
1556 mInputMethodContext.SetRestoreAfterFocusLost( false );
1558 // Notify that the text editing finish.
1559 mInputMethodContext.Deactivate();
1561 mInputMethodContext.EventReceivedSignal().Disconnect( this, &TextField::OnInputMethodContextEvent );
1563 ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
1567 notifier.ContentSelectedSignal().Disconnect( this, &TextField::OnClipboardTextSelected );
1570 mController->KeyboardFocusLostEvent();
1572 EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
1575 bool TextField::OnAccessibilityActivated()
1581 void TextField::OnTap( const TapGesture& gesture )
1583 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnTap %p\n", mController.Get() );
1584 if ( mInputMethodContext && IsEditable() )
1586 mInputMethodContext.Activate();
1588 // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
1590 padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1591 const Vector2& localPoint = gesture.GetLocalPoint();
1592 mController->TapEvent( gesture.GetNumberOfTaps(), localPoint.x - padding.start, localPoint.y - padding.top );
1597 void TextField::OnPan( const PanGesture& gesture )
1599 mController->PanEvent( gesture.GetState(), gesture.GetDisplacement() );
1602 void TextField::OnLongPress( const LongPressGesture& gesture )
1604 if ( mInputMethodContext && IsEditable() )
1606 mInputMethodContext.Activate();
1609 padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1610 const Vector2& localPoint = gesture.GetLocalPoint();
1611 mController->LongPressEvent( gesture.GetState(), localPoint.x - padding.start, localPoint.y - padding.top );
1616 bool TextField::OnKeyEvent( const KeyEvent& event )
1618 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.GetKeyCode() );
1620 if( Dali::DALI_KEY_ESCAPE == event.GetKeyCode() && mController->ShouldClearFocusOnEscape() )
1622 // Make sure ClearKeyInputFocus when only key is up
1623 if( event.GetState() == KeyEvent::UP )
1625 ClearKeyInputFocus();
1630 else if( Dali::DevelKey::DALI_KEY_RETURN == event.GetKeyCode() )
1632 // Do nothing when enter is comming.
1636 return mController->KeyEvent( event );
1639 void TextField::RequestTextRelayout()
1644 bool TextField::IsEditable() const
1646 return mController->IsEditable();
1649 void TextField::SetEditable( bool editable )
1651 mController->SetEditable(editable);
1652 if ( mInputMethodContext && !editable )
1654 mInputMethodContext.Deactivate();
1658 void TextField::TextInserted( unsigned int position, unsigned int length, const std::string &content )
1660 if( Accessibility::IsUp() )
1662 Control::Impl::GetAccessibilityObject( Self() )->EmitTextInserted( position, length, content );
1666 void TextField::TextDeleted( unsigned int position, unsigned int length, const std::string &content )
1668 if( Accessibility::IsUp() )
1670 Control::Impl::GetAccessibilityObject( Self() )->EmitTextDeleted( position, length, content );
1674 void TextField::CaretMoved( unsigned int position )
1676 if( Accessibility::IsUp() )
1678 Control::Impl::GetAccessibilityObject( Self() )->EmitTextCaretMoved( position );
1682 void TextField::TextChanged()
1684 Dali::Toolkit::TextField handle( GetOwner() );
1685 mTextChangedSignal.Emit( handle );
1688 void TextField::MaxLengthReached()
1690 Dali::Toolkit::TextField handle( GetOwner() );
1691 mMaxLengthReachedSignal.Emit( handle );
1694 void TextField::InputStyleChanged( Text::InputStyle::Mask inputStyleMask )
1696 Dali::Toolkit::TextField handle( GetOwner() );
1698 Toolkit::TextField::InputStyle::Mask fieldInputStyleMask = Toolkit::TextField::InputStyle::NONE;
1700 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_COLOR ) )
1702 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::COLOR );
1704 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_FAMILY ) )
1706 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_FAMILY );
1708 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_POINT_SIZE ) )
1710 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::POINT_SIZE );
1712 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_WEIGHT ) )
1714 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE );
1716 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_WIDTH ) )
1718 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE );
1720 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_SLANT ) )
1722 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE );
1724 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_UNDERLINE ) )
1726 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::UNDERLINE );
1728 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_SHADOW ) )
1730 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::SHADOW );
1732 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_EMBOSS ) )
1734 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::EMBOSS );
1736 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_OUTLINE ) )
1738 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::OUTLINE );
1741 mInputStyleChangedSignal.Emit( handle, fieldInputStyleMask );
1744 void TextField::AddDecoration( Actor& actor, bool needsClipping )
1750 mClippingDecorationActors.push_back( actor );
1754 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1755 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1756 Self().Add( actor );
1757 mActiveLayer = actor;
1762 void TextField::OnSceneConnect( Dali::Actor actor )
1764 if ( mHasBeenStaged )
1766 RenderText( static_cast<Text::Controller::UpdateTextType>( Text::Controller::MODEL_UPDATED | Text::Controller::DECORATOR_UPDATED ) );
1770 mHasBeenStaged = true;
1774 InputMethodContext::CallbackData TextField::OnInputMethodContextEvent( Dali::InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent )
1776 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnInputMethodContextEvent %p eventName %d\n", mController.Get(), inputMethodContextEvent.eventName );
1777 return mController->OnInputMethodContextEvent( inputMethodContext, inputMethodContextEvent );
1780 void TextField::GetHandleImagePropertyValue( Property::Value& value, Text::HandleType handleType, Text::HandleImageType handleImageType )
1785 map[ IMAGE_MAP_FILENAME_STRING ] = mDecorator->GetHandleImage( handleType, handleImageType );
1790 void TextField::EnableClipping()
1794 // Creates an extra control to be used as stencil buffer.
1795 mStencil = Control::New();
1796 mStencil.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1797 mStencil.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1799 // Creates a background visual. Even if the color is transparent it updates the stencil.
1800 mStencil.SetProperty( Toolkit::Control::Property::BACKGROUND,
1801 Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR ).
1802 Add( ColorVisual::Property::MIX_COLOR, Color::TRANSPARENT ) );
1804 // Enable the clipping property.
1805 mStencil.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
1806 mStencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
1808 Self().Add( mStencil );
1812 void TextField::OnClipboardTextSelected( ClipboardEventNotifier& clipboard )
1814 mController->PasteClipboardItemEvent();
1817 void TextField::KeyboardStatusChanged(bool keyboardShown)
1819 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown );
1821 // Just hide the grab handle when keyboard is hidden.
1822 if (!keyboardShown )
1824 mController->KeyboardFocusLostEvent();
1828 mController->KeyboardFocusGainEvent(); // Initially called by OnKeyInputFocusGained
1832 void TextField::OnSceneConnection( int depth )
1834 // Sets the depth to the visuals inside the text's decorator.
1835 mDecorator->SetTextDepth( depth );
1837 // The depth of the text renderer is set in the RenderText() called from OnRelayout().
1839 // Call the Control::OnSceneConnection() to set the depth of the background.
1840 Control::OnSceneConnection( depth );
1843 bool TextField::OnTouched( Actor actor, const TouchEvent& touch )
1848 void TextField::OnIdleSignal()
1850 // Emits the change of input style signals.
1851 mController->ProcessInputStyleChangedSignals();
1853 // Set the pointer to null as the callback manager deletes the callback after execute it.
1854 mIdleCallback = NULL;
1857 TextField::TextField()
1858 : Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
1859 mIdleCallback( NULL ),
1860 mAlignmentOffset( 0.f ),
1861 mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
1862 mExceedPolicy( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ),
1863 mHasBeenStaged( false )
1867 TextField::~TextField()
1869 UnparentAndReset( mStencil );
1871 if( ( NULL != mIdleCallback ) && Adaptor::IsAvailable() )
1873 Adaptor::Get().RemoveIdle( mIdleCallback );
1877 std::string TextField::AccessibleImpl::GetName()
1879 auto slf = Toolkit::TextField::DownCast( self );
1880 return slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get< std::string >();
1883 std::string TextField::AccessibleImpl::GetText( size_t startOffset,
1886 if( endOffset <= startOffset )
1889 auto slf = Toolkit::TextField::DownCast( self );
1891 slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get< std::string >();
1893 if( startOffset > txt.size() || endOffset > txt.size() )
1896 return txt.substr( startOffset, endOffset - startOffset );
1899 size_t TextField::AccessibleImpl::GetCharacterCount()
1901 auto slf = Toolkit::TextField::DownCast( self );
1903 slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get< std::string >();
1908 size_t TextField::AccessibleImpl::GetCaretOffset()
1910 auto slf = Toolkit::TextField::DownCast( self );
1911 return Dali::Toolkit::GetImpl( slf ).getController()->GetCursorPosition();
1914 bool TextField::AccessibleImpl::SetCaretOffset(size_t offset)
1916 auto slf = Toolkit::TextField::DownCast( self );
1917 auto txt = slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get< std::string >();
1918 if (offset > txt.size())
1921 auto& slfImpl = Dali::Toolkit::GetImpl( slf );
1922 slfImpl.getController()->ResetCursorPosition( offset );
1923 slfImpl.RequestTextRelayout();
1927 Dali::Accessibility::Range TextField::AccessibleImpl::GetTextAtOffset(
1928 size_t offset, Dali::Accessibility::TextBoundary boundary )
1930 auto slf = Toolkit::TextField::DownCast( self );
1931 auto txt = slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get< std::string >();
1932 auto txt_size = txt.size();
1934 auto range = Dali::Accessibility::Range{};
1938 case Dali::Accessibility::TextBoundary::CHARACTER:
1940 if (offset < txt_size)
1942 range.content = txt[offset];
1943 range.startOffset = offset;
1944 range.endOffset = offset + 1;
1948 case Dali::Accessibility::TextBoundary::WORD:
1949 case Dali::Accessibility::TextBoundary::LINE:
1951 auto txt_c_string = txt.c_str();
1952 auto breaks = std::vector< char >( txt_size, 0 );
1953 if(boundary == Dali::Accessibility::TextBoundary::WORD)
1954 Accessibility::Accessible::FindWordSeparationsUtf8((const utf8_t *) txt_c_string, txt_size, "", breaks.data());
1956 Accessibility::Accessible::FindLineSeparationsUtf8((const utf8_t *) txt_c_string, txt_size, "", breaks.data());
1959 while( index < txt_size && counter <= offset )
1964 while(breaks[index])
1970 if (boundary == Dali::Accessibility::TextBoundary::WORD)
1972 if (boundary == Dali::Accessibility::TextBoundary::LINE)
1975 if ((counter > 0) && ((counter - 1) == offset))
1977 range.content = txt.substr(start, index - start + 1);
1978 range.startOffset = start;
1979 range.endOffset = index + 1;
1981 if (boundary == Dali::Accessibility::TextBoundary::LINE)
1986 case Dali::Accessibility::TextBoundary::SENTENCE:
1988 /* not supported by efl */
1991 case Dali::Accessibility::TextBoundary::PARAGRAPH:
1993 /* Paragraph is not supported by libunibreak library */
2003 Dali::Accessibility::Range
2004 TextField::AccessibleImpl::GetSelection( size_t selectionNum )
2006 // Since DALi supports only one selection indexes higher than 0 are ignored
2007 if( selectionNum > 0 )
2010 auto slf = Toolkit::TextField::DownCast( self );
2011 auto ctrl = Dali::Toolkit::GetImpl( slf ).getController();
2013 ctrl->RetrieveSelection( ret );
2014 auto r = ctrl->GetSelectionIndexes();
2016 return { static_cast<size_t>(r.first), static_cast<size_t>(r.second), ret };
2019 bool TextField::AccessibleImpl::RemoveSelection( size_t selectionNum )
2021 // Since DALi supports only one selection indexes higher than 0 are ignored
2022 if( selectionNum > 0 )
2025 auto slf = Toolkit::TextField::DownCast( self );
2026 Dali::Toolkit::GetImpl( slf ).getController()->SetSelection( 0, 0 );
2030 bool TextField::AccessibleImpl::SetSelection( size_t selectionNum,
2034 // Since DALi supports only one selection indexes higher than 0 are ignored
2035 if( selectionNum > 0 )
2038 auto slf = Toolkit::TextField::DownCast( self );
2039 Dali::Toolkit::GetImpl( slf ).getController()->SetSelection( startOffset,
2044 bool TextField::AccessibleImpl::CopyText( size_t startPosition,
2045 size_t endPosition )
2047 if( endPosition <= startPosition )
2050 auto slf = Toolkit::TextField::DownCast( self );
2051 auto txt = slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get<std::string>();
2052 Dali::Toolkit::GetImpl( slf ).getController()->CopyStringToClipboard( txt.substr(startPosition, endPosition - startPosition) );
2057 bool TextField::AccessibleImpl::CutText( size_t startPosition,
2058 size_t endPosition )
2060 if( endPosition <= startPosition )
2063 auto slf = Toolkit::TextField::DownCast( self );
2064 auto txt = slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get<std::string>();
2065 Dali::Toolkit::GetImpl( slf ).getController()->CopyStringToClipboard( txt.substr(startPosition, endPosition - startPosition) );
2067 slf.SetProperty( Toolkit::TextField::Property::TEXT,
2068 txt.substr( 0, startPosition ) + txt.substr( endPosition - startPosition, txt.size()));
2073 Dali::Accessibility::States TextField::AccessibleImpl::CalculateStates()
2075 using namespace Dali::Accessibility;
2077 auto states = Control::Impl::AccessibleImpl::CalculateStates();
2079 states[State::EDITABLE] = true;
2080 states[State::FOCUSABLE] = true;
2082 Toolkit::Control focusControl = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl();
2083 if (self == focusControl)
2085 states[State::FOCUSED] = true;
2091 } // namespace Internal
2093 } // namespace Toolkit