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/public-api/object/type-registry.h>
27 #include <dali/public-api/object/type-registry-helper.h>
28 #include <dali/public-api/scripting/scripting.h>
29 #include <dali/integration-api/debug.h>
30 #include <dali/public-api/adaptor-framework/virtual-keyboard.h>
33 #include <dali-toolkit/public-api/text/rendering-backend.h>
34 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
35 #include <dali-toolkit/internal/text/rendering/text-backend.h>
36 #include <dali-toolkit/internal/styling/style-manager-impl.h>
38 using namespace Dali::Toolkit::Text;
51 const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
57 const Scripting::StringEnum< Toolkit::Text::LayoutEngine::HorizontalAlignment > HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
59 { "BEGIN", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN },
60 { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
61 { "END", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_END },
63 const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
65 const Scripting::StringEnum< Toolkit::Text::LayoutEngine::VerticalAlignment > VERTICAL_ALIGNMENT_STRING_TABLE[] =
67 { "TOP", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_TOP },
68 { "CENTER", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_CENTER },
69 { "BOTTOM", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_BOTTOM },
71 const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] );
76 return Toolkit::TextField::New();
79 // Setup properties, signals and actions using the type-registry.
80 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextField, Toolkit::Control, Create );
82 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "rendering-backend", INTEGER, RENDERING_BACKEND )
83 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholder-text", STRING, PLACEHOLDER_TEXT )
84 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "text", STRING, TEXT )
85 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "font-family", STRING, FONT_FAMILY )
86 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "font-style", STRING, FONT_STYLE )
87 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "point-size", FLOAT, POINT_SIZE )
88 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "exceed-policy", INTEGER, EXCEED_POLICY )
89 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "horizontal-alignment", STRING, HORIZONTAL_ALIGNMENT )
90 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "vertical-alignment", STRING, VERTICAL_ALIGNMENT )
91 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "text-color", VECTOR4, TEXT_COLOR )
92 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadow-offset", VECTOR2, SHADOW_OFFSET )
93 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadow-color", VECTOR4, SHADOW_COLOR )
94 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "primary-cursor-color", VECTOR4, PRIMARY_CURSOR_COLOR )
95 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "secondary-cursor-color", VECTOR4, SECONDARY_CURSOR_COLOR )
96 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enable-cursor-blink", BOOLEAN, ENABLE_CURSOR_BLINK )
97 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursor-blink-interval", FLOAT, CURSOR_BLINK_INTERVAL )
98 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursor-blink-duration", FLOAT, CURSOR_BLINK_DURATION )
99 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "grab-handle-image", STRING, GRAB_HANDLE_IMAGE )
100 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "grab-handle-pressed-image", VECTOR4, GRAB_HANDLE_PRESSED_IMAGE )
101 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "scroll-threshold", FLOAT, SCROLL_THRESHOLD )
102 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "scroll-speed", FLOAT, SCROLL_SPEED )
103 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-image-left", STRING, SELECTION_HANDLE_IMAGE_LEFT )
104 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-image-right", STRING, SELECTION_HANDLE_IMAGE_RIGHT )
105 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-pressed-image-left", STRING, SELECTION_HANDLE_PRESSED_IMAGE_LEFT )
106 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-pressed-image-right", STRING, SELECTION_HANDLE_PRESSED_IMAGE_RIGHT )
107 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-highlight-color", STRING, SELECTION_HIGHLIGHT_COLOR )
108 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "decoration-bounding-box", RECTANGLE, DECORATION_BOUNDING_BOX )
110 DALI_TYPE_REGISTRATION_END()
114 Toolkit::TextField TextField::New()
116 // Create the implementation, temporarily owned by this handle on stack
117 IntrusivePtr< TextField > impl = new TextField();
119 // Pass ownership to CustomActor handle
120 Toolkit::TextField handle( *impl );
122 // Second-phase init of the implementation
123 // This can only be done after the CustomActor connection has been made...
129 void TextField::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
131 Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
135 TextField& impl( GetImpl( textField ) );
139 case Toolkit::TextField::Property::RENDERING_BACKEND:
141 int backend = value.Get< int >();
143 if( impl.mRenderingBackend != backend )
145 impl.mRenderingBackend = backend;
146 impl.mRenderer.Reset();
150 case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
152 if( impl.mController )
154 //impl.mController->SetPlaceholderText( value.Get< std::string >() ); TODO
158 case Toolkit::TextField::Property::TEXT:
160 if( impl.mController )
162 impl.mController->SetText( value.Get< std::string >() );
166 case Toolkit::TextField::Property::FONT_FAMILY:
168 if( impl.mController )
170 std::string fontFamily = value.Get< std::string >();
172 if( impl.mController->GetDefaultFontFamily() != fontFamily )
174 impl.mController->SetDefaultFontFamily( fontFamily );
175 impl.RequestTextRelayout();
180 case Toolkit::TextField::Property::FONT_STYLE:
182 if( impl.mController )
184 std::string fontStyle = value.Get< std::string >();
186 if( impl.mController->GetDefaultFontStyle() != fontStyle )
188 impl.mController->SetDefaultFontStyle( fontStyle );
189 impl.RequestTextRelayout();
194 case Toolkit::TextField::Property::POINT_SIZE:
196 if( impl.mController )
198 float pointSize = value.Get< float >();
200 if( !Equals( impl.mController->GetDefaultPointSize(), pointSize ) )
202 impl.mController->SetDefaultPointSize( pointSize );
203 impl.RequestTextRelayout();
208 case Toolkit::TextField::Property::EXCEED_POLICY:
210 impl.mExceedPolicy = value.Get< int >();
213 case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
215 LayoutEngine& engine = impl.mController->GetLayoutEngine();
216 const LayoutEngine::HorizontalAlignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::HorizontalAlignment >( value.Get< std::string >().c_str(),
217 HORIZONTAL_ALIGNMENT_STRING_TABLE,
218 HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
220 if( engine.GetHorizontalAlignment() != alignment )
222 engine.SetHorizontalAlignment( alignment );
223 impl.RequestTextRelayout();
227 case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
229 LayoutEngine& engine = impl.mController->GetLayoutEngine();
230 const LayoutEngine::VerticalAlignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::VerticalAlignment >( value.Get< std::string >().c_str(),
231 VERTICAL_ALIGNMENT_STRING_TABLE,
232 VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
234 if( engine.GetVerticalAlignment() != alignment )
236 engine.SetVerticalAlignment( alignment );
237 impl.RequestTextRelayout();
241 case Toolkit::TextField::Property::TEXT_COLOR:
243 if ( impl.mController )
245 Vector4 textColor = value.Get< Vector4 >();
246 if ( impl.mController->GetTextColor() != textColor )
248 impl.mController->SetTextColor( textColor );
249 impl.RequestTextRelayout();
254 case Toolkit::TextField::Property::SHADOW_OFFSET:
256 if( impl.mController )
258 Vector2 shadowOffset = value.Get< Vector2 >();
259 if ( impl.mController->GetShadowOffset() != shadowOffset )
261 impl.mController->SetShadowOffset( shadowOffset );
262 impl.RequestTextRelayout();
267 case Toolkit::TextField::Property::SHADOW_COLOR:
269 if( impl.mController )
271 Vector4 shadowColor = value.Get< Vector4 >();
272 if ( impl.mController->GetShadowColor() != shadowColor )
274 impl.mController->SetShadowColor( shadowColor );
275 impl.RequestTextRelayout();
280 case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
282 if( impl.mDecorator )
284 impl.mDecorator->SetColor( PRIMARY_CURSOR, value.Get< Vector4 >() );
288 case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
290 if( impl.mDecorator )
292 impl.mDecorator->SetColor( SECONDARY_CURSOR, value.Get< Vector4 >() );
296 case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
298 if( impl.mController )
300 impl.mController->SetEnableCursorBlink( value.Get< bool >() );
304 case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
306 if( impl.mDecorator )
308 impl.mDecorator->SetCursorBlinkInterval( value.Get< float >() );
312 case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
314 if( impl.mDecorator )
316 impl.mDecorator->SetCursorBlinkDuration( value.Get< float >() );
320 case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
322 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
324 if( impl.mDecorator )
326 impl.mDecorator->SetGrabHandleImage( GRAB_HANDLE_IMAGE_RELEASED, image );
330 case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
332 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
334 if( impl.mDecorator )
336 impl.mDecorator->SetGrabHandleImage( GRAB_HANDLE_IMAGE_PRESSED, image );
340 case Toolkit::TextField::Property::SCROLL_THRESHOLD:
342 float threshold = value.Get< float >();
344 if( impl.mDecorator )
346 impl.mDecorator->SetScrollThreshold( threshold );
350 case Toolkit::TextField::Property::SCROLL_SPEED:
352 float speed = value.Get< float >();
354 if( impl.mDecorator )
356 impl.mDecorator->SetScrollSpeed( speed );
360 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
362 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
364 if( impl.mDecorator )
366 impl.mDecorator->SetLeftSelectionImage( SELECTION_HANDLE_RELEASED, image );
370 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
372 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
374 if( impl.mDecorator )
376 impl.mDecorator->SetRightSelectionImage( SELECTION_HANDLE_RELEASED, image );
380 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
382 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
384 if( impl.mDecorator )
386 impl.mDecorator->SetLeftSelectionImage( SELECTION_HANDLE_PRESSED, image );
390 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
392 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
394 if( impl.mDecorator )
396 impl.mDecorator->SetLeftSelectionImage( SELECTION_HANDLE_PRESSED, image );
400 case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
402 Vector4 color = value.Get< Vector4 >();
404 if( impl.mDecorator )
406 impl.mDecorator->SetHighlightColor( color );
410 case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
412 if( impl.mDecorator )
414 impl.mDecorator->SetBoundingBox( value.Get< Rect<int> >() );
422 Property::Value TextField::GetProperty( BaseObject* object, Property::Index index )
424 Property::Value value;
426 Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
430 TextField& impl( GetImpl( textField ) );
434 case Toolkit::TextField::Property::RENDERING_BACKEND:
436 value = impl.mRenderingBackend;
439 case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
441 if( impl.mController )
444 impl.mController->GetPlaceholderText( text );
449 case Toolkit::TextField::Property::TEXT:
451 if( impl.mController )
454 impl.mController->GetText( text );
459 case Toolkit::TextField::Property::EXCEED_POLICY:
461 value = impl.mExceedPolicy;
464 case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
466 if( impl.mController )
468 value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(),
469 HORIZONTAL_ALIGNMENT_STRING_TABLE,
470 HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ) );
474 case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
476 if( impl.mController )
478 value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetLayoutEngine().GetVerticalAlignment(),
479 VERTICAL_ALIGNMENT_STRING_TABLE,
480 VERTICAL_ALIGNMENT_STRING_TABLE_COUNT ) );
484 case Toolkit::TextField::Property::TEXT_COLOR:
486 if ( impl.mController )
488 value = impl.mController->GetTextColor();
492 case Toolkit::TextField::Property::SHADOW_OFFSET:
494 if ( impl.mController )
496 value = impl.mController->GetShadowOffset();
500 case Toolkit::TextField::Property::SHADOW_COLOR:
502 if ( impl.mController )
504 value = impl.mController->GetShadowColor();
508 case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
510 if( impl.mDecorator )
512 value = impl.mDecorator->GetColor( PRIMARY_CURSOR );
516 case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
518 if( impl.mDecorator )
520 value = impl.mDecorator->GetColor( SECONDARY_CURSOR );
524 case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
526 value = impl.mController->GetEnableCursorBlink();
529 case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
531 if( impl.mDecorator )
533 value = impl.mDecorator->GetCursorBlinkInterval();
537 case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
539 if( impl.mDecorator )
541 value = impl.mDecorator->GetCursorBlinkDuration();
545 case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
547 if( impl.mDecorator )
549 ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetGrabHandleImage( GRAB_HANDLE_IMAGE_RELEASED ) );
552 value = image.GetUrl();
557 case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
559 if( impl.mDecorator )
561 ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetGrabHandleImage( GRAB_HANDLE_IMAGE_PRESSED ) );
564 value = image.GetUrl();
569 case Toolkit::TextField::Property::SCROLL_THRESHOLD:
571 if( impl.mDecorator )
573 value = impl.mDecorator->GetScrollThreshold();
577 case Toolkit::TextField::Property::SCROLL_SPEED:
579 if( impl.mDecorator )
581 value = impl.mDecorator->GetScrollSpeed();
585 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
587 if( impl.mDecorator )
589 ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetLeftSelectionImage( SELECTION_HANDLE_RELEASED ) );
592 value = image.GetUrl();
597 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
599 if( impl.mDecorator )
601 ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetRightSelectionImage( SELECTION_HANDLE_RELEASED ) );
604 value = image.GetUrl();
609 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
611 if( impl.mDecorator )
613 ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetLeftSelectionImage( SELECTION_HANDLE_PRESSED ) );
616 value = image.GetUrl();
621 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
623 if( impl.mDecorator )
625 ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetRightSelectionImage( SELECTION_HANDLE_PRESSED ) );
628 value = image.GetUrl();
633 case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
635 if( impl.mDecorator )
637 value = impl.mDecorator->GetHighlightColor();
641 case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
643 if( impl.mDecorator )
645 value = impl.mDecorator->GetBoundingBox();
655 void TextField::OnInitialize()
659 mController = Text::Controller::New( *this );
661 mDecorator = Text::Decorator::New( *this, *mController );
663 mController->GetLayoutEngine().SetLayout( LayoutEngine::SINGLE_LINE_BOX );
665 mController->EnableTextInput( mDecorator );
667 // Forward input events to controller
668 EnableGestureDetection(Gesture::Tap);
669 GetTapGestureDetector().SetMaximumTapsRequired( 2 );
670 EnableGestureDetection(Gesture::Pan);
672 // Set BoundingBox to stage size if not already set.
673 if ( mDecorator->GetBoundingBox().IsEmpty() )
675 Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
676 mDecorator->SetBoundingBox( Rect<int>( 0.0f, 0.0f, stageSize.width, stageSize.height ) );
679 // Fill-parent area by default
680 self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
681 self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
684 void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
686 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
689 Vector3 TextField::GetNaturalSize()
691 return mController->GetNaturalSize();
694 float TextField::GetHeightForWidth( float width )
696 return mController->GetHeightForWidth( width );
699 void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
701 if( mController->Relayout( size ) ||
706 mDecorator->Relayout( size );
711 mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
714 RenderableActor renderableActor;
717 renderableActor = mRenderer->Render( mController->GetView() );
720 EnableClipping( (Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy), size );
722 if( renderableActor != mRenderableActor )
724 UnparentAndReset( mRenderableActor );
725 mRenderableActor = renderableActor;
728 if( mRenderableActor )
730 const Vector2 offset = mController->GetScrollPosition() + mController->GetAlignmentOffset();
732 mRenderableActor.SetPosition( offset.x, offset.y );
734 // Make sure the actor is parented correctly with/without clipping
737 mClipper->GetRootActor().Add( mRenderableActor );
741 Self().Add( mRenderableActor );
747 void TextField::OnKeyInputFocusGained()
749 VirtualKeyboard::StatusChangedSignal().Connect( this, &TextField::KeyboardStatusChanged );
751 ImfManager imfManager = ImfManager::Get();
755 imfManager.EventReceivedSignal().Connect( this, &TextField::OnImfEvent );
757 // Notify that the text editing start.
758 imfManager.Activate();
760 // When window gain lost focus, the imf manager is deactivated. Thus when window gain focus again, the imf manager must be activated.
761 imfManager.SetRestoreAfterFocusLost( true );
764 mController->KeyboardFocusGainEvent();
766 EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
769 void TextField::OnKeyInputFocusLost()
771 VirtualKeyboard::StatusChangedSignal().Disconnect( this, &TextField::KeyboardStatusChanged );
773 ImfManager imfManager = ImfManager::Get();
776 // The text editing is finished. Therefore the imf manager don't have restore activation.
777 imfManager.SetRestoreAfterFocusLost( false );
779 // Notify that the text editing finish.
780 imfManager.Deactivate();
782 imfManager.EventReceivedSignal().Disconnect( this, &TextField::OnImfEvent );
785 mController->KeyboardFocusLostEvent();
787 EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
790 void TextField::OnTap( const TapGesture& gesture )
792 // Show the keyboard if it was hidden.
793 if (!VirtualKeyboard::IsVisible())
795 VirtualKeyboard::Show();
800 mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x, gesture.localPoint.y );
803 void TextField::OnPan( const PanGesture& gesture )
805 mController->PanEvent( gesture.state, gesture.displacement );
808 bool TextField::OnKeyEvent( const KeyEvent& event )
810 if( Dali::DALI_KEY_ESCAPE == event.keyCode )
812 ClearKeyInputFocus();
815 return mController->KeyEvent( event );
818 ImfManager::ImfCallbackData TextField::OnImfEvent( Dali::ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
820 switch ( imfEvent.eventName )
822 case ImfManager::COMMIT:
824 KeyEvent event( "", imfEvent.predictiveString, 0, 0, 0, KeyEvent::Down );
825 mController->KeyEvent( event );
828 case ImfManager::PREEDIT: // fall through
829 case ImfManager::DELETESURROUNDING:
830 case ImfManager::GETSURROUNDING:
831 case ImfManager::VOID:
837 return ImfManager::ImfCallbackData();
840 void TextField::RequestTextRelayout()
845 void TextField::EnableClipping( bool clipping, const Vector2& size )
849 // Not worth to created clip actor if width or height is equal to zero.
850 if( size.width > Math::MACHINE_EPSILON_1000 && size.height > Math::MACHINE_EPSILON_1000 )
856 mClipper = Clipper::New( size );
857 self.Add( mClipper->GetRootActor() );
858 self.Add( mClipper->GetImageActor() );
862 mClipper->Refresh( size );
868 // Note - this will automatically remove the root & image actors
873 void TextField::KeyboardStatusChanged(bool keyboardShown)
875 // Just hide the grab handle when keyboard is hidden.
878 mController->KeyboardFocusLostEvent();
882 TextField::TextField()
883 : Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
884 mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
885 mExceedPolicy( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP )
889 TextField::~TextField()
894 } // namespace Internal
896 } // namespace Toolkit