2 * Copyright (c) 2015 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/stage.h>
25 #include <dali/public-api/images/resource-image.h>
26 #include <dali/devel-api/adaptor-framework/virtual-keyboard.h>
27 #include <dali/public-api/object/type-registry-helper.h>
28 #include <dali/integration-api/debug.h>
31 #include <dali-toolkit/public-api/text/rendering-backend.h>
32 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
33 #include <dali-toolkit/internal/text/rendering/text-backend.h>
34 #include <dali-toolkit/internal/text/text-effects-style.h>
35 #include <dali-toolkit/internal/text/text-font-style.h>
36 #include <dali-toolkit/internal/text/text-view.h>
37 #include <dali-toolkit/internal/styling/style-manager-impl.h>
39 using namespace Dali::Toolkit::Text;
50 namespace // unnamed namespace
53 #if defined(DEBUG_ENABLED)
54 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS");
57 const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
58 } // unnamed namespace
63 const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
65 { "BEGIN", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN },
66 { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
67 { "END", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_END },
69 const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
71 const Scripting::StringEnum VERTICAL_ALIGNMENT_STRING_TABLE[] =
73 { "TOP", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_TOP },
74 { "CENTER", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_CENTER },
75 { "BOTTOM", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_BOTTOM },
77 const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] );
82 return Toolkit::TextField::New();
85 // Setup properties, signals and actions using the type-registry.
86 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextField, Toolkit::Control, Create );
88 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "renderingBackend", INTEGER, RENDERING_BACKEND )
89 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "text", STRING, TEXT )
90 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholderText", STRING, PLACEHOLDER_TEXT )
91 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholderTextFocused", STRING, PLACEHOLDER_TEXT_FOCUSED )
92 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "fontFamily", STRING, FONT_FAMILY )
93 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "fontStyle", STRING, FONT_STYLE )
94 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "pointSize", FLOAT, POINT_SIZE )
95 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "maxLength", INTEGER, MAX_LENGTH )
96 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "exceedPolicy", INTEGER, EXCEED_POLICY )
97 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "horizontalAlignment", STRING, HORIZONTAL_ALIGNMENT )
98 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "verticalAlignment", STRING, VERTICAL_ALIGNMENT )
99 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "textColor", VECTOR4, TEXT_COLOR )
100 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholderTextColor", VECTOR4, PLACEHOLDER_TEXT_COLOR )
101 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadowOffset", VECTOR2, SHADOW_OFFSET )
102 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadowColor", VECTOR4, SHADOW_COLOR )
103 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "primaryCursorColor", VECTOR4, PRIMARY_CURSOR_COLOR )
104 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "secondaryCursorColor", VECTOR4, SECONDARY_CURSOR_COLOR )
105 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enableCursorBlink", BOOLEAN, ENABLE_CURSOR_BLINK )
106 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursorBlinkInterval", FLOAT, CURSOR_BLINK_INTERVAL )
107 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursorBlinkDuration", FLOAT, CURSOR_BLINK_DURATION )
108 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursorWidth", INTEGER, CURSOR_WIDTH )
109 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "grabHandleImage", STRING, GRAB_HANDLE_IMAGE )
110 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "grabHandlePressedImage", STRING, GRAB_HANDLE_PRESSED_IMAGE )
111 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "scrollThreshold", FLOAT, SCROLL_THRESHOLD )
112 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "scrollSpeed", FLOAT, SCROLL_SPEED )
113 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandleImageLeft", MAP, SELECTION_HANDLE_IMAGE_LEFT )
114 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandleImageRight", MAP, SELECTION_HANDLE_IMAGE_RIGHT )
115 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandlePressedImageLeft", MAP, SELECTION_HANDLE_PRESSED_IMAGE_LEFT )
116 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandlePressedImageRight", MAP, SELECTION_HANDLE_PRESSED_IMAGE_RIGHT )
117 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandleMarkerImageLeft", MAP, SELECTION_HANDLE_MARKER_IMAGE_LEFT )
118 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandleMarkerImageRight", MAP, SELECTION_HANDLE_MARKER_IMAGE_RIGHT )
119 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHighlightColor", VECTOR4, SELECTION_HIGHLIGHT_COLOR )
120 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "decorationBoundingBox", RECTANGLE, DECORATION_BOUNDING_BOX )
121 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputMethodSettings", MAP, INPUT_METHOD_SETTINGS )
122 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputColor", VECTOR4, INPUT_COLOR )
123 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enableMarkup", BOOLEAN, ENABLE_MARKUP )
124 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputFontFamily", STRING, INPUT_FONT_FAMILY )
125 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputFontStyle", STRING, INPUT_FONT_STYLE )
126 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputPointSize", FLOAT, INPUT_POINT_SIZE )
127 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "underline", STRING, UNDERLINE )
128 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputUnderline", STRING, INPUT_UNDERLINE )
129 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadow", STRING, SHADOW )
130 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputShadow", STRING, INPUT_SHADOW )
131 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "emboss", STRING, EMBOSS )
132 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputEmboss", STRING, INPUT_EMBOSS )
133 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "outline", STRING, OUTLINE )
134 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputOutline", STRING, INPUT_OUTLINE )
136 DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED )
137 DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED )
139 DALI_TYPE_REGISTRATION_END()
143 Toolkit::TextField TextField::New()
145 // Create the implementation, temporarily owned by this handle on stack
146 IntrusivePtr< TextField > impl = new TextField();
148 // Pass ownership to CustomActor handle
149 Toolkit::TextField handle( *impl );
151 // Second-phase init of the implementation
152 // This can only be done after the CustomActor connection has been made...
158 void TextField::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
160 Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
162 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField SetProperty\n");
167 TextField& impl( GetImpl( textField ) );
171 case Toolkit::TextField::Property::RENDERING_BACKEND:
173 int backend = value.Get< int >();
174 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p RENDERING_BACKEND %d\n", impl.mController.Get(), backend );
176 #ifndef ENABLE_VECTOR_BASED_TEXT_RENDERING
177 if( Text::RENDERING_VECTOR_BASED == backend )
179 backend = TextAbstraction::BITMAP_GLYPH; // Fallback to bitmap-based rendering
182 if( impl.mRenderingBackend != backend )
184 impl.mRenderingBackend = backend;
185 impl.mRenderer.Reset();
187 if( impl.mController )
189 // When using the vector-based rendering, the size of the GLyphs are different
190 TextAbstraction::GlyphType glyphType = (Text::RENDERING_VECTOR_BASED == impl.mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
191 impl.mController->SetGlyphType( glyphType );
196 case Toolkit::TextField::Property::TEXT:
198 if( impl.mController )
200 const std::string text = value.Get< std::string >();
201 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p TEXT %s\n", impl.mController.Get(), text.c_str() );
203 impl.mController->SetText( text );
207 case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
209 if( impl.mController )
211 const std::string text = value.Get< std::string >();
212 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str() );
214 impl.mController->SetPlaceholderText( PLACEHOLDER_TYPE_INACTIVE, text );
218 case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED:
220 if( impl.mController )
222 const std::string text = value.Get< std::string >();
223 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_FOCUSED %s\n", impl.mController.Get(), text.c_str() );
225 impl.mController->SetPlaceholderText( PLACEHOLDER_TYPE_ACTIVE, text );
229 case Toolkit::TextField::Property::FONT_FAMILY:
231 if( impl.mController )
233 const std::string fontFamily = value.Get< std::string >();
234 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
235 impl.mController->SetDefaultFontFamily( fontFamily );
239 case Toolkit::TextField::Property::FONT_STYLE:
241 SetFontStyleProperty( impl.mController, value, Text::FontStyle::DEFAULT );
244 case Toolkit::TextField::Property::POINT_SIZE:
246 if( impl.mController )
248 const float pointSize = value.Get< float >();
249 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p POINT_SIZE %f\n", impl.mController.Get(), pointSize );
251 if( !Equals( impl.mController->GetDefaultPointSize(), pointSize ) )
253 impl.mController->SetDefaultPointSize( pointSize );
258 case Toolkit::TextField::Property::MAX_LENGTH:
260 if( impl.mController )
262 const int max = value.Get< int >();
263 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p MAX_LENGTH %d\n", impl.mController.Get(), max );
265 impl.mController->SetMaximumNumberOfCharacters( max );
269 case Toolkit::TextField::Property::EXCEED_POLICY:
274 case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
276 if( impl.mController )
278 const std::string alignStr = value.Get< std::string >();
279 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p HORIZONTAL_ALIGNMENT %s\n", impl.mController.Get(), alignStr.c_str() );
281 LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN );
282 if( Scripting::GetEnumeration< LayoutEngine::HorizontalAlignment >( alignStr.c_str(),
283 HORIZONTAL_ALIGNMENT_STRING_TABLE,
284 HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
287 impl.mController->SetHorizontalAlignment( alignment );
292 case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
294 if( impl.mController )
296 const std::string alignStr = value.Get< std::string >();
297 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p VERTICAL_ALIGNMENT %s\n", impl.mController.Get(), alignStr.c_str() );
299 LayoutEngine::VerticalAlignment alignment( LayoutEngine::VERTICAL_ALIGN_BOTTOM );
300 if( Scripting::GetEnumeration< LayoutEngine::VerticalAlignment >( alignStr.c_str(),
301 VERTICAL_ALIGNMENT_STRING_TABLE,
302 VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
305 impl.mController->SetVerticalAlignment( alignment );
310 case Toolkit::TextField::Property::TEXT_COLOR:
312 if( impl.mController )
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->GetTextColor() != textColor )
319 impl.mController->SetTextColor( textColor );
320 impl.mController->SetInputColor( textColor );
321 impl.mRenderer.Reset();
326 case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR:
328 if( impl.mController )
330 const Vector4 textColor = value.Get< Vector4 >();
331 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 );
333 if( impl.mController->GetPlaceholderTextColor() != textColor )
335 impl.mController->SetPlaceholderTextColor( textColor );
336 impl.mRenderer.Reset();
341 case Toolkit::TextField::Property::SHADOW_OFFSET:
343 if( impl.mController )
345 const Vector2 shadowOffset = value.Get< Vector2 >();
346 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SHADOW_OFFSET %f,%f\n", impl.mController.Get(), shadowOffset.x, shadowOffset.y );
348 if ( impl.mController->GetShadowOffset() != shadowOffset )
350 impl.mController->SetShadowOffset( shadowOffset );
351 impl.mRenderer.Reset();
356 case Toolkit::TextField::Property::SHADOW_COLOR:
358 if( impl.mController )
360 const Vector4 shadowColor = value.Get< Vector4 >();
361 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SHADOW_COLOR %f,%f,%f,%f\n", impl.mController.Get(), shadowColor.r, shadowColor.g, shadowColor.b, shadowColor.a );
363 if ( impl.mController->GetShadowColor() != shadowColor )
365 impl.mController->SetShadowColor( shadowColor );
366 impl.mRenderer.Reset();
371 case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
373 if( impl.mDecorator )
375 const Vector4 color = value.Get< Vector4 >();
376 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 );
378 impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color );
379 impl.RequestTextRelayout();
383 case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
385 if( impl.mDecorator )
387 const Vector4 color = value.Get< Vector4 >();
388 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 );
390 impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color );
391 impl.RequestTextRelayout();
395 case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
397 if( impl.mController )
399 const bool enable = value.Get< bool >();
400 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable );
402 impl.mController->SetEnableCursorBlink( enable );
403 impl.RequestTextRelayout();
407 case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
409 if( impl.mDecorator )
411 const float interval = value.Get< float >();
412 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval );
414 impl.mDecorator->SetCursorBlinkInterval( interval );
418 case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
420 if( impl.mDecorator )
422 const float duration = value.Get< float >();
423 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration );
425 impl.mDecorator->SetCursorBlinkDuration( duration );
429 case Toolkit::TextField::Property::CURSOR_WIDTH:
431 if( impl.mDecorator )
433 const int width = value.Get< int >();
434 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_WIDTH %d\n", impl.mController.Get(), width );
436 impl.mDecorator->SetCursorWidth( width );
437 impl.mController->GetLayoutEngine().SetCursorWidth( width );
441 case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
443 const ResourceImage image = ResourceImage::New( value.Get< std::string >() );
444 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), image.GetUrl().c_str() );
446 if( impl.mDecorator )
448 impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED, image );
449 impl.RequestTextRelayout();
453 case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
455 const ResourceImage image = ResourceImage::New( value.Get< std::string >() );
456 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), image.GetUrl().c_str() );
458 if( impl.mDecorator )
460 impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED, image );
461 impl.RequestTextRelayout();
465 case Toolkit::TextField::Property::SCROLL_THRESHOLD:
467 const float threshold = value.Get< float >();
468 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold );
470 if( impl.mDecorator )
472 impl.mDecorator->SetScrollThreshold( threshold );
476 case Toolkit::TextField::Property::SCROLL_SPEED:
478 const float speed = value.Get< float >();
479 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p SCROLL_SPEED %f\n", impl.mController.Get(), speed );
481 if( impl.mDecorator )
483 impl.mDecorator->SetScrollSpeed( speed );
487 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
489 const Image image = Scripting::NewImage( value );
491 if( impl.mDecorator && image )
493 impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image );
494 impl.RequestTextRelayout();
498 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
500 const Image image = Scripting::NewImage( value );
502 if( impl.mDecorator && image )
504 impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image );
505 impl.RequestTextRelayout();
509 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
511 const Image image = Scripting::NewImage( value );
513 if( impl.mDecorator && image )
515 impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image );
516 impl.RequestTextRelayout();
520 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
522 const Image image = Scripting::NewImage( value );
524 if( impl.mDecorator && image )
526 impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image );
527 impl.RequestTextRelayout();
531 case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
533 const Image image = Scripting::NewImage( value );
535 if( impl.mDecorator && image )
537 impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, image );
538 impl.RequestTextRelayout();
542 case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
544 const Image image = Scripting::NewImage( value );
546 if( impl.mDecorator && image )
548 impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, image );
549 impl.RequestTextRelayout();
553 case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
555 const Vector4 color = value.Get< Vector4 >();
556 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 );
558 if( impl.mDecorator )
560 impl.mDecorator->SetHighlightColor( color );
561 impl.RequestTextRelayout();
565 case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
567 if( impl.mDecorator )
569 const Rect<int> box = value.Get< Rect<int> >();
570 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 );
572 impl.mDecorator->SetBoundingBox( box );
573 impl.RequestTextRelayout();
577 case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS:
579 const Property::Map map = value.Get<Property::Map>();
580 VirtualKeyboard::ApplySettings( map );
583 case Toolkit::TextField::Property::INPUT_COLOR:
585 if( impl.mController )
587 const Vector4 inputColor = value.Get< Vector4 >();
588 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 );
590 impl.mController->SetInputColor( inputColor );
594 case Toolkit::TextField::Property::ENABLE_MARKUP:
596 if( impl.mController )
598 const bool enableMarkup = value.Get<bool>();
599 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup );
601 impl.mController->SetMarkupProcessorEnabled( enableMarkup );
605 case Toolkit::TextField::Property::INPUT_FONT_FAMILY:
607 if( impl.mController )
609 const std::string fontFamily = value.Get< std::string >();
610 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
611 impl.mController->SetInputFontFamily( fontFamily );
615 case Toolkit::TextField::Property::INPUT_FONT_STYLE:
617 SetFontStyleProperty( impl.mController, value, Text::FontStyle::INPUT );
620 case Toolkit::TextField::Property::INPUT_POINT_SIZE:
622 if( impl.mController )
624 const float pointSize = value.Get< float >();
625 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize );
626 impl.mController->SetInputFontPointSize( pointSize );
630 case Toolkit::TextField::Property::UNDERLINE:
632 const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
635 impl.mRenderer.Reset();
639 case Toolkit::TextField::Property::INPUT_UNDERLINE:
641 const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
644 impl.mRenderer.Reset();
648 case Toolkit::TextField::Property::SHADOW:
650 const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
653 impl.mRenderer.Reset();
657 case Toolkit::TextField::Property::INPUT_SHADOW:
659 const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT );
662 impl.mRenderer.Reset();
666 case Toolkit::TextField::Property::EMBOSS:
668 const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
671 impl.mRenderer.Reset();
675 case Toolkit::TextField::Property::INPUT_EMBOSS:
677 const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT );
680 impl.mRenderer.Reset();
684 case Toolkit::TextField::Property::OUTLINE:
686 const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
689 impl.mRenderer.Reset();
693 case Toolkit::TextField::Property::INPUT_OUTLINE:
695 const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
698 impl.mRenderer.Reset();
706 Property::Value TextField::GetProperty( BaseObject* object, Property::Index index )
708 Property::Value value;
710 Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
714 TextField& impl( GetImpl( textField ) );
718 case Toolkit::TextField::Property::RENDERING_BACKEND:
720 value = impl.mRenderingBackend;
723 case Toolkit::TextField::Property::TEXT:
725 if( impl.mController )
728 impl.mController->GetText( text );
729 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p returning text: %s\n", impl.mController.Get(), text.c_str() );
734 case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
736 if( impl.mController )
739 impl.mController->GetPlaceholderText( PLACEHOLDER_TYPE_INACTIVE, text );
744 case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED:
746 if( impl.mController )
749 impl.mController->GetPlaceholderText( PLACEHOLDER_TYPE_ACTIVE, text );
754 case Toolkit::TextField::Property::FONT_FAMILY:
756 if( impl.mController )
758 value = impl.mController->GetDefaultFontFamily();
762 case Toolkit::TextField::Property::FONT_STYLE:
764 GetFontStyleProperty( impl.mController, value, Text::FontStyle::DEFAULT );
767 case Toolkit::TextField::Property::POINT_SIZE:
769 if( impl.mController )
771 value = impl.mController->GetDefaultPointSize();
775 case Toolkit::TextField::Property::MAX_LENGTH:
777 if( impl.mController )
779 value = impl.mController->GetMaximumNumberOfCharacters();
783 case Toolkit::TextField::Property::EXCEED_POLICY:
785 value = impl.mExceedPolicy;
788 case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
790 if( impl.mController )
792 const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(),
793 HORIZONTAL_ALIGNMENT_STRING_TABLE,
794 HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
797 value = std::string( name );
802 case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
804 if( impl.mController )
806 const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetLayoutEngine().GetVerticalAlignment(),
807 VERTICAL_ALIGNMENT_STRING_TABLE,
808 VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
811 value = std::string( name );
816 case Toolkit::TextField::Property::TEXT_COLOR:
818 if ( impl.mController )
820 value = impl.mController->GetTextColor();
824 case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR:
826 if ( impl.mController )
828 value = impl.mController->GetPlaceholderTextColor();
832 case Toolkit::TextField::Property::SHADOW_OFFSET:
834 if ( impl.mController )
836 value = impl.mController->GetShadowOffset();
840 case Toolkit::TextField::Property::SHADOW_COLOR:
842 if ( impl.mController )
844 value = impl.mController->GetShadowColor();
848 case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
850 if( impl.mDecorator )
852 value = impl.mDecorator->GetColor( PRIMARY_CURSOR );
856 case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
858 if( impl.mDecorator )
860 value = impl.mDecorator->GetColor( SECONDARY_CURSOR );
864 case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
866 value = impl.mController->GetEnableCursorBlink();
869 case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
871 if( impl.mDecorator )
873 value = impl.mDecorator->GetCursorBlinkInterval();
877 case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
879 if( impl.mDecorator )
881 value = impl.mDecorator->GetCursorBlinkDuration();
885 case Toolkit::TextField::Property::CURSOR_WIDTH:
887 if( impl.mDecorator )
889 value = impl.mDecorator->GetCursorWidth();
893 case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
895 if( impl.mDecorator )
897 ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED ) );
900 value = image.GetUrl();
905 case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
907 if( impl.mDecorator )
909 ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED ) );
912 value = image.GetUrl();
917 case Toolkit::TextField::Property::SCROLL_THRESHOLD:
919 if( impl.mDecorator )
921 value = impl.mDecorator->GetScrollThreshold();
925 case Toolkit::TextField::Property::SCROLL_SPEED:
927 if( impl.mDecorator )
929 value = impl.mDecorator->GetScrollSpeed();
933 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
935 impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED );
938 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
940 impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED ) ;
943 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
945 impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED );
948 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
950 impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED );
953 case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
955 impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED );
958 case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
960 impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED );
963 case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
965 if( impl.mDecorator )
967 value = impl.mDecorator->GetHighlightColor();
971 case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
973 if( impl.mDecorator )
975 Rect<int> boundingBox;
976 impl.mDecorator->GetBoundingBox( boundingBox );
981 case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS:
985 case Toolkit::TextField::Property::INPUT_COLOR:
987 if( impl.mController )
989 value = impl.mController->GetInputColor();
993 case Toolkit::TextField::Property::ENABLE_MARKUP:
995 if( impl.mController )
997 value = impl.mController->IsMarkupProcessorEnabled();
1001 case Toolkit::TextField::Property::INPUT_FONT_FAMILY:
1003 if( impl.mController )
1005 value = impl.mController->GetInputFontFamily();
1009 case Toolkit::TextField::Property::INPUT_FONT_STYLE:
1011 GetFontStyleProperty( impl.mController, value, Text::FontStyle::INPUT );
1014 case Toolkit::TextField::Property::INPUT_POINT_SIZE:
1016 if( impl.mController )
1018 value = impl.mController->GetInputFontPointSize();
1022 case Toolkit::TextField::Property::UNDERLINE:
1024 GetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
1027 case Toolkit::TextField::Property::INPUT_UNDERLINE:
1029 GetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
1032 case Toolkit::TextField::Property::SHADOW:
1034 GetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
1037 case Toolkit::TextField::Property::INPUT_SHADOW:
1039 GetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT );
1042 case Toolkit::TextField::Property::EMBOSS:
1044 GetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
1047 case Toolkit::TextField::Property::INPUT_EMBOSS:
1049 GetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT );
1052 case Toolkit::TextField::Property::OUTLINE:
1054 GetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
1057 case Toolkit::TextField::Property::INPUT_OUTLINE:
1059 GetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
1068 bool TextField::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
1070 Dali::BaseHandle handle( object );
1072 bool connected( true );
1073 Toolkit::TextField field = Toolkit::TextField::DownCast( handle );
1075 if( 0 == strcmp( signalName.c_str(), SIGNAL_TEXT_CHANGED ) )
1077 field.TextChangedSignal().Connect( tracker, functor );
1079 else if( 0 == strcmp( signalName.c_str(), SIGNAL_MAX_LENGTH_REACHED ) )
1081 field.MaxLengthReachedSignal().Connect( tracker, functor );
1085 // signalName does not match any signal
1092 Toolkit::TextField::TextChangedSignalType& TextField::TextChangedSignal()
1094 return mTextChangedSignal;
1097 Toolkit::TextField::MaxLengthReachedSignalType& TextField::MaxLengthReachedSignal()
1099 return mMaxLengthReachedSignal;
1102 void TextField::OnInitialize()
1104 Actor self = Self();
1106 mController = Text::Controller::New( *this );
1108 // When using the vector-based rendering, the size of the GLyphs are different
1109 TextAbstraction::GlyphType glyphType = (Text::RENDERING_VECTOR_BASED == mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
1110 mController->SetGlyphType( glyphType );
1112 mDecorator = Text::Decorator::New( *mController,
1115 mController->GetLayoutEngine().SetLayout( LayoutEngine::SINGLE_LINE_BOX );
1117 mController->EnableTextInput( mDecorator );
1119 // Forward input events to controller
1120 EnableGestureDetection( static_cast<Gesture::Type>( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) );
1121 GetTapGestureDetector().SetMaximumTapsRequired( 2 );
1123 self.TouchSignal().Connect( this, &TextField::OnTouched );
1125 // Set BoundingBox to stage size if not already set.
1126 Rect<int> boundingBox;
1127 mDecorator->GetBoundingBox( boundingBox );
1129 if( boundingBox.IsEmpty() )
1131 Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
1132 mDecorator->SetBoundingBox( Rect<int>( 0.0f, 0.0f, stageSize.width, stageSize.height ) );
1135 // Flip vertically the 'left' selection handle
1136 mDecorator->FlipHandleVertically( LEFT_SELECTION_HANDLE, true );
1138 // Fill-parent area by default
1139 self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
1140 self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
1141 self.OnStageSignal().Connect( this, &TextField::OnStageConnect );
1144 void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
1146 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange\n");
1150 case StyleChange::DEFAULT_FONT_CHANGE:
1152 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n");
1153 const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily();
1154 // Property system did not set the font so should update it.
1155 mController->UpdateAfterFontChange( newFont );
1159 case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
1161 DALI_LOG_INFO( gLogFilter, Debug::General, "TextField::OnStyleChange StyleChange::DEFAULT_FONT_SIZE_CHANGE (%f)\n", mController->GetDefaultPointSize() );
1163 if ( (mController->GetDefaultPointSize() <= 0.0f) ) // If DefaultPointSize not set by Property system it will be 0.0f
1165 // Property system did not set the PointSize so should update it.
1166 // todo instruct text-controller to update model
1170 case StyleChange::THEME_CHANGE:
1172 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
1178 Vector3 TextField::GetNaturalSize()
1180 return mController->GetNaturalSize();
1183 float TextField::GetHeightForWidth( float width )
1185 return mController->GetHeightForWidth( width );
1188 void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
1190 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField OnRelayout\n");
1192 const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size );
1194 if( ( Text::Controller::NONE_UPDATED != updateTextType ) ||
1197 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnRelayout %p Displaying new contents\n", mController.Get() );
1200 ( Text::Controller::NONE_UPDATED != ( Text::Controller::DECORATOR_UPDATED & updateTextType ) ) )
1202 mDecorator->Relayout( size );
1207 mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
1210 EnableClipping( ( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy ), size );
1211 RenderText( updateTextType );
1215 void TextField::RenderText( Text::Controller::UpdateTextType updateTextType )
1217 Actor self = Self();
1218 Actor renderableActor;
1220 if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
1224 renderableActor = mRenderer->Render( mController->GetView(), DepthIndex::TEXT );
1227 if( renderableActor != mRenderableActor )
1229 UnparentAndReset( mRenderableActor );
1230 mRenderableActor = renderableActor;
1234 if( mRenderableActor )
1236 const Vector2& scrollOffset = mController->GetScrollPosition();
1238 mRenderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
1240 Actor clipRootActor;
1243 clipRootActor = mClipper->GetRootActor();
1246 for( std::vector<Actor>::const_iterator it = mClippingDecorationActors.begin(),
1247 endIt = mClippingDecorationActors.end();
1255 clipRootActor.Add( actor );
1262 mClippingDecorationActors.clear();
1264 // Make sure the actor is parented correctly with/without clipping
1267 clipRootActor.Add( mRenderableActor );
1271 self.Add( mRenderableActor );
1276 void TextField::OnKeyInputFocusGained()
1278 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() );
1280 VirtualKeyboard::StatusChangedSignal().Connect( this, &TextField::KeyboardStatusChanged );
1282 ImfManager imfManager = ImfManager::Get();
1286 imfManager.EventReceivedSignal().Connect( this, &TextField::OnImfEvent );
1288 // Notify that the text editing start.
1289 imfManager.Activate();
1291 // When window gain lost focus, the imf manager is deactivated. Thus when window gain focus again, the imf manager must be activated.
1292 imfManager.SetRestoreAfterFocusLost( true );
1295 ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
1299 notifier.ContentSelectedSignal().Connect( this, &TextField::OnClipboardTextSelected );
1302 mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event
1304 EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
1307 void TextField::OnKeyInputFocusLost()
1309 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField:OnKeyInputFocusLost %p\n", mController.Get() );
1311 VirtualKeyboard::StatusChangedSignal().Disconnect( this, &TextField::KeyboardStatusChanged );
1313 ImfManager imfManager = ImfManager::Get();
1316 // The text editing is finished. Therefore the imf manager don't have restore activation.
1317 imfManager.SetRestoreAfterFocusLost( false );
1319 // Notify that the text editing finish.
1320 imfManager.Deactivate();
1322 imfManager.EventReceivedSignal().Disconnect( this, &TextField::OnImfEvent );
1325 ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
1329 notifier.ContentSelectedSignal().Disconnect( this, &TextField::OnClipboardTextSelected );
1332 mController->KeyboardFocusLostEvent();
1334 EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
1337 void TextField::OnTap( const TapGesture& gesture )
1339 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnTap %p\n", mController.Get() );
1341 // Show the keyboard if it was hidden.
1342 if (!VirtualKeyboard::IsVisible())
1344 VirtualKeyboard::Show();
1347 // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
1348 mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x, gesture.localPoint.y );
1353 void TextField::OnPan( const PanGesture& gesture )
1355 mController->PanEvent( gesture.state, gesture.displacement );
1358 void TextField::OnLongPress( const LongPressGesture& gesture )
1360 // Show the keyboard if it was hidden.
1361 if (!VirtualKeyboard::IsVisible())
1363 VirtualKeyboard::Show();
1366 mController->LongPressEvent( gesture.state, gesture.localPoint.x, gesture.localPoint.y );
1371 bool TextField::OnKeyEvent( const KeyEvent& event )
1373 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.keyCode );
1375 if( Dali::DALI_KEY_ESCAPE == event.keyCode ||
1376 "Return" == event.keyPressedName ) // Make a Dali key code for this
1378 ClearKeyInputFocus();
1382 return mController->KeyEvent( event );
1385 void TextField::AddDecoration( Actor& actor, bool needsClipping )
1391 mClippingDecorationActors.push_back( actor );
1395 Self().Add( actor );
1400 void TextField::RequestTextRelayout()
1405 void TextField::TextChanged()
1407 Dali::Toolkit::TextField handle( GetOwner() );
1408 mTextChangedSignal.Emit( handle );
1411 void TextField::OnStageConnect( Dali::Actor actor )
1413 if ( mHasBeenStaged )
1415 RenderText( static_cast<Text::Controller::UpdateTextType>( Text::Controller::MODEL_UPDATED | Text::Controller::DECORATOR_UPDATED ) );
1419 mHasBeenStaged = true;
1423 void TextField::MaxLengthReached()
1425 Dali::Toolkit::TextField handle( GetOwner() );
1426 mMaxLengthReachedSignal.Emit( handle );
1429 ImfManager::ImfCallbackData TextField::OnImfEvent( Dali::ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
1431 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnImfEvent %p eventName %d\n", mController.Get(), imfEvent.eventName );
1432 return mController->OnImfEvent( imfManager, imfEvent );
1435 void TextField::GetHandleImagePropertyValue( Property::Value& value, Text::HandleType handleType, Text::HandleImageType handleImageType )
1439 ResourceImage image = ResourceImage::DownCast( mDecorator->GetHandleImage( handleType, handleImageType ) );
1444 Scripting::CreatePropertyMap( image, map );
1450 void TextField::EnableClipping( bool clipping, const Vector2& size )
1454 // Not worth to created clip actor if width or height is equal to zero.
1455 if( size.width > Math::MACHINE_EPSILON_1000 && size.height > Math::MACHINE_EPSILON_1000 )
1459 Actor self = Self();
1461 mClipper = Clipper::New( size );
1462 self.Add( mClipper->GetRootActor() );
1463 self.Add( mClipper->GetImageView() );
1465 else if ( mClipper )
1467 mClipper->Refresh( size );
1473 // Note - this will automatically remove the root actor & the image view
1478 void TextField::OnClipboardTextSelected( ClipboardEventNotifier& clipboard )
1480 mController->PasteClipboardItemEvent();
1483 void TextField::KeyboardStatusChanged(bool keyboardShown)
1485 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown );
1487 // Just hide the grab handle when keyboard is hidden.
1488 if (!keyboardShown )
1490 mController->KeyboardFocusLostEvent();
1494 mController->KeyboardFocusGainEvent(); // Initially called by OnKeyInputFocusGained
1498 void TextField::OnStageConnection( int depth )
1500 // Call the Control::OnStageConnection() to set the depth of the background.
1501 Control::OnStageConnection( depth );
1503 // Sets the depth to the renderers inside the text's decorator.
1504 mDecorator->SetTextDepth( depth );
1506 // The depth of the text renderer is set in the RenderText() called from OnRelayout().
1509 bool TextField::OnTouched( Actor actor, const TouchData& touch )
1514 TextField::TextField()
1515 : Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
1516 mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
1517 mExceedPolicy( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ),
1518 mHasBeenStaged( false )
1522 TextField::~TextField()
1527 } // namespace Internal
1529 } // namespace Toolkit