#include <dali-toolkit/internal/controls/text-controls/text-field-impl.h>
// EXTERNAL INCLUDES
-#include <string>
-#include <iostream>
#include <cstring>
#include <dali/public-api/adaptor-framework/key.h>
#include <dali/public-api/common/stage.h>
#include <dali/public-api/images/resource-image.h>
-#include <dali/public-api/object/type-registry.h>
-#include <dali/devel-api/object/type-registry-helper.h>
-#include <dali/devel-api/scripting/scripting.h>
#include <dali/devel-api/adaptor-framework/virtual-keyboard.h>
+#include <dali/devel-api/object/type-registry-helper.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/text/rendering-backend.h>
-#include <dali-toolkit/internal/text/layouts/layout-engine.h>
+#include <dali-toolkit/internal/controls/text-controls/text-font-style.h>
#include <dali-toolkit/internal/text/rendering/text-backend.h>
#include <dali-toolkit/internal/text/text-view.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
#endif
const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
-
} // unnamed namespace
namespace
{
Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField SetProperty\n");
+
+
if( textField )
{
TextField& impl( GetImpl( textField ) );
if( impl.mController->GetDefaultFontFamily() != fontFamily )
{
- impl.mController->SetDefaultFontFamily( fontFamily );
+ impl.mController->SetDefaultFontFamily( fontFamily, true ); // "true" as SetProperty means user defined font so don't change when system font changes.
}
}
break;
}
case Toolkit::TextField::Property::FONT_STYLE:
{
- if( impl.mController )
- {
- const std::string fontStyle = value.Get< std::string >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_STYLE %s\n", impl.mController.Get(), fontStyle.c_str() );
-
- if( impl.mController->GetDefaultFontStyle() != fontStyle )
- {
- impl.mController->SetDefaultFontStyle( fontStyle );
- }
- }
+ SetFontStyleProperty( impl.mController, value );
break;
}
case Toolkit::TextField::Property::POINT_SIZE:
{
const Image image = Scripting::NewImage( value );
- if( impl.mDecorator )
+ if( impl.mDecorator && image )
{
impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image );
impl.RequestTextRelayout();
{
const Image image = Scripting::NewImage( value );
- if( impl.mDecorator )
+ if( impl.mDecorator && image )
{
impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image );
impl.RequestTextRelayout();
{
const Image image = Scripting::NewImage( value );
- if( impl.mDecorator )
+ if( impl.mDecorator && image )
{
impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image );
impl.RequestTextRelayout();
{
const Image image = Scripting::NewImage( value );
- if( impl.mDecorator )
+ if( impl.mDecorator && image )
{
impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image );
impl.RequestTextRelayout();
case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
{
const Image image = Scripting::NewImage( value );
- if( impl.mDecorator )
+
+ if( impl.mDecorator && image )
{
impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, image );
impl.RequestTextRelayout();
case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
{
const Image image = Scripting::NewImage( value );
- if( impl.mDecorator )
+
+ if( impl.mDecorator && image )
{
impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, image );
impl.RequestTextRelayout();
}
case Toolkit::TextField::Property::FONT_STYLE:
{
- if( impl.mController )
- {
- value = impl.mController->GetDefaultFontStyle();
- }
+ GetFontStyleProperty( impl.mController, value );
break;
}
case Toolkit::TextField::Property::POINT_SIZE:
{
if( impl.mDecorator )
{
- value = impl.mDecorator->GetBoundingBox();
+ Rect<int> boundingBox;
+ impl.mDecorator->GetBoundingBox( boundingBox );
+ value = boundingBox;
}
break;
}
self.TouchedSignal().Connect( this, &TextField::OnTouched );
// Set BoundingBox to stage size if not already set.
- if ( mDecorator->GetBoundingBox().IsEmpty() )
+ Rect<int> boundingBox;
+ mDecorator->GetBoundingBox( boundingBox );
+
+ if( boundingBox.IsEmpty() )
{
Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
mDecorator->SetBoundingBox( Rect<int>( 0.0f, 0.0f, stageSize.width, stageSize.height ) );
{
case StyleChange::DEFAULT_FONT_CHANGE:
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField::OnStyleChange StyleChange::DEFAULT_FONT_CHANGE\n");
- if ( mController->GetDefaultFontFamily() == "" )
- {
- // Property system did not set the font so should update it.
- // todo instruct text-controller to update model
- }
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n");
+ std::string newFont = styleManager.GetDefaultFontFamily();
+ // Property system did not set the font so should update it.
+ mController->UpdateAfterFontChange( newFont );
break;
}
void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField OnRelayout\n");
+
if( mController->Relayout( size ) ||
!mRenderer )
{
void TextField::OnLongPress( const LongPressGesture& gesture )
{
+ // Show the keyboard if it was hidden.
+ if (!VirtualKeyboard::IsVisible())
+ {
+ VirtualKeyboard::Show();
+ }
+
mController->LongPressEvent( gesture.state, gesture.localPoint.x, gesture.localPoint.y );
+
+ SetKeyInputFocus();
}
bool TextField::OnKeyEvent( const KeyEvent& event )