Change-Id: Id7db01da8f8476f56873b5f97a5e07e046882fe9
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/integration-api/debug.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/adaptor-framework/virtual-keyboard.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/text/rendering-backend.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/text/rendering-backend.h>
{
if( impl.mController )
{
{
if( impl.mController )
{
- //impl.mController->SetEnableCursorBlink( value.Get< bool >() ); TODO
+ impl.mController->SetEnableCursorBlink( value.Get< bool >() );
}
case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
{
}
case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
{
- //value = impl.mController->GetEnableCursorBlink(); TODO
+ value = impl.mController->GetEnableCursorBlink();
break;
}
case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
break;
}
case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
+void TextField::OnKeyInputFocusGained()
+{
+ VirtualKeyboard::StatusChangedSignal().Connect( this, &TextField::KeyboardStatusChanged );
+
+ mController->KeyboardFocusGainEvent();
+}
+
+void TextField::OnKeyInputFocusLost()
+{
+ VirtualKeyboard::StatusChangedSignal().Disconnect( this, &TextField::KeyboardStatusChanged );
+
+ mController->KeyboardFocusLostEvent();
+}
+
void TextField::OnTap( const TapGesture& gesture )
{
void TextField::OnTap( const TapGesture& gesture )
{
+ // Show the keyboard if it was hidden.
+ if (!VirtualKeyboard::IsVisible())
+ {
+ VirtualKeyboard::Show();
+ }
+
SetKeyInputFocus();
mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x, gesture.localPoint.y );
SetKeyInputFocus();
mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x, gesture.localPoint.y );
+void TextField::KeyboardStatusChanged(bool keyboardShown)
+{
+ // Just hide the grab handle when keyboard is hidden.
+ if (!keyboardShown )
+ {
+ mController->KeyboardFocusLostEvent();
+ }
+}
+
TextField::TextField()
: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
TextField::TextField()
: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
/**
virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
/**
+ * @copydoc Control::OnKeyInputFocusGained()
+ */
+ virtual void OnKeyInputFocusGained();
+
+ /**
+ * @copydoc Control::OnKeyInputFocusLost()
+ */
+ virtual void OnKeyInputFocusLost();
+
+ /**
* Received for single & double taps
*/
virtual void OnTap( const TapGesture& tap );
* Received for single & double taps
*/
virtual void OnTap( const TapGesture& tap );
void EnableClipping( bool clipping, const Vector2& size );
/**
void EnableClipping( bool clipping, const Vector2& size );
/**
+ * @brief Callback when keyboard is shown/hidden.
+ *
+ * @param[in] keyboardShown True if keyboard is shown.
+ */
+ void KeyboardStatusChanged( bool keyboardShown );
+
+ /**
* Construct a new TextField.
*/
TextField();
* Construct a new TextField.
*/
TextField();
: mLogicalModel( logicalModel ),
mVisualModel( visualModel ),
mDecorator( decorator ),
: mLogicalModel( logicalModel ),
mVisualModel( visualModel ),
mDecorator( decorator ),
+ mState( INACTIVE ),
+ mDecoratorUpdated( false ),
+ mCursorBlinkEnabled( true )
void OnKeyboardFocus( bool hasFocus )
{
void OnKeyboardFocus( bool hasFocus )
{
+ if( !hasFocus )
+ {
+ ChangeState( INACTIVE );
+ }
+ else
+ {
+ ChangeState( EDITING );
+ }
}
void OnKeyEvent( const Event& event )
}
void OnKeyEvent( const Event& event )
else if( EDITING == mState )
{
mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
else if( EDITING == mState )
{
mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
- mDecorator->StartCursorBlink();
+ if( mCursorBlinkEnabled )
+ {
+ mDecorator->StartCursorBlink();
+ }
mDecorator->SetGrabHandleActive( true );
mDecorator->SetSelectionActive( false );
mDecoratorUpdated = true;
mDecorator->SetGrabHandleActive( true );
mDecorator->SetSelectionActive( false );
mDecoratorUpdated = true;
- bool mDecoratorUpdated;
+ bool mDecoratorUpdated : 1;
+ bool mCursorBlinkEnabled : 1;
};
struct Controller::FontDefaults
};
struct Controller::FontDefaults
+void Controller::SetEnableCursorBlink( bool enable )
+{
+ DALI_ASSERT_DEBUG( NULL != mImpl->mTextInput && "TextInput disabled" );
+
+ if( mImpl->mTextInput )
+ {
+ mImpl->mTextInput->mCursorBlinkEnabled = enable;
+
+ if( !enable &&
+ mImpl->mTextInput->mDecorator )
+ {
+ mImpl->mTextInput->mDecorator->StopCursorBlink();
+ }
+ }
+}
+
+bool Controller::GetEnableCursorBlink() const
+{
+ if( mImpl->mTextInput )
+ {
+ return mImpl->mTextInput->mCursorBlinkEnabled;
+ }
+
+ return false;
+}
+
bool Controller::Relayout( const Vector2& size )
{
if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) )
{
bool Controller::Relayout( const Vector2& size )
{
if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) )
{
+ bool glyphsRemoved( false );
+ if( 0u != mImpl->mVisualModel->GetNumberOfGlyphPositions() )
+ {
+ mImpl->mVisualModel->SetGlyphPositions( NULL, 0u );
+ glyphsRemoved = true;
+ }
+
// Not worth to relayout if width or height is equal to zero.
// Not worth to relayout if width or height is equal to zero.
}
if( size != mImpl->mControlSize )
}
if( size != mImpl->mControlSize )
*
* @return The default font family.
*/
*
* @return The default font family.
*/
- const std::string& GetDefaultFontFamily() const;
+ const std::string& GetDefaultFontFamily() const;
/**
* @brief Set the default font style.
/**
* @brief Set the default font style.
*
* @return The default font style.
*/
*
* @return The default font style.
*/
- const std::string& GetDefaultFontStyle() const;
+ const std::string& GetDefaultFontStyle() const;
/**
* @brief Set the default point size.
/**
* @brief Set the default point size.
*
* @return The default point size.
*/
*
* @return The default point size.
*/
- float GetDefaultPointSize() const;
+ float GetDefaultPointSize() const;
/**
* @brief Retrieve the default fonts.
/**
* @brief Retrieve the default fonts.
* @param[out] fonts The default font family, style and point sizes.
* @param[in] numberOfCharacters The number of characters in the logical model.
*/
* @param[out] fonts The default font family, style and point sizes.
* @param[in] numberOfCharacters The number of characters in the logical model.
*/
- void GetDefaultFonts( Dali::Vector<FontRun>& fonts, Length numberOfCharacters );
+ void GetDefaultFonts( Dali::Vector<FontRun>& fonts, Length numberOfCharacters );
/**
* @brief Called to enable text input.
/**
* @brief Called to enable text input.
void EnableTextInput( DecoratorPtr decorator );
/**
void EnableTextInput( DecoratorPtr decorator );
/**
+ * @brief Called to enable/disable cursor blink.
+ *
+ * @note Only editable controls should calls this.
+ * @param[in] enabled Whether the cursor should blink or not.
+ */
+ void SetEnableCursorBlink( bool enable );
+
+ /**
+ * @brief Query whether cursor blink is enabled.
+ *
+ * @return Whether the cursor should blink or not.
+ */
+ bool GetEnableCursorBlink() const;
+
+ /**
* @brief Triggers a relayout which updates View (if necessary).
*
* @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
* @brief Triggers a relayout which updates View (if necessary).
*
* @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.