mTextDepth( 0u ),
mActiveCopyPastePopup( false ),
mCursorBlinkStatus( true ),
+ mDelayCursorBlink( false ),
mPrimaryCursorVisible( false ),
mSecondaryCursorVisible( false ),
mSwapSelectionHandles( false ),
position.y );
mPrimaryCursor.SetSize( Size( mCursorWidth, cursor.cursorHeight ) );
}
- mPrimaryCursor.SetVisible( mPrimaryCursorVisible );
+ mPrimaryCursor.SetVisible( mPrimaryCursorVisible && mCursorBlinkStatus );
}
if( mSecondaryCursor )
{
cursor.position.y );
mSecondaryCursor.SetSize( Size( mCursorWidth, cursor.cursorHeight ) );
}
- mSecondaryCursor.SetVisible( mSecondaryCursorVisible );
+ mSecondaryCursor.SetVisible( mSecondaryCursorVisible && mCursorBlinkStatus );
}
// Show or hide the grab handle
bool OnCursorBlinkTimerTick()
{
- // Cursor blinking
- if ( mPrimaryCursor )
+ if( !mDelayCursorBlink )
{
- mPrimaryCursor.SetVisible( mPrimaryCursorVisible && mCursorBlinkStatus );
+ // Cursor blinking
+ if ( mPrimaryCursor )
+ {
+ mPrimaryCursor.SetVisible( mPrimaryCursorVisible && mCursorBlinkStatus );
+ }
+ if ( mSecondaryCursor )
+ {
+ mSecondaryCursor.SetVisible( mSecondaryCursorVisible && mCursorBlinkStatus );
+ }
+
+ mCursorBlinkStatus = !mCursorBlinkStatus;
}
- if ( mSecondaryCursor )
+ else
{
- mSecondaryCursor.SetVisible( mSecondaryCursorVisible && mCursorBlinkStatus );
+ // Resume blinking
+ mDelayCursorBlink = false;
}
- mCursorBlinkStatus = !mCursorBlinkStatus;
-
return true;
}
bool mActiveCopyPastePopup : 1;
bool mCursorBlinkStatus : 1; ///< Flag to switch between blink on and blink off.
+ bool mDelayCursorBlink : 1; ///< Used to avoid cursor blinking when entering text.
bool mPrimaryCursorVisible : 1; ///< Whether the primary cursor is visible.
bool mSecondaryCursorVisible : 1; ///< Whether the secondary cursor is visible.
bool mSwapSelectionHandles : 1; ///< Whether to swap the selection handle images.
{
mImpl->mCursorBlinkTimer.Stop();
}
+
+ mImpl->mCursorBlinkStatus = true; // Keep cursor permanently shown
+}
+
+void Decorator::DelayCursorBlink()
+{
+ mImpl->mCursorBlinkStatus = true; // Show cursor for a bit longer
+ mImpl->mDelayCursorBlink = true;
}
void Decorator::SetCursorBlinkInterval( float seconds )
if( 1u == tapCount )
{
- if( ! IsShowingPlaceholderText() )
+ if( IsShowingRealText() )
{
const float xPosition = event.p2.mFloat - mEventData->mScrollPosition.x - mAlignmentOffset.x;
const float yPosition = event.p3.mFloat - mEventData->mScrollPosition.y - mAlignmentOffset.y;
mEventData->mPrimaryCursorPosition = GetClosestCursorIndex( xPosition,
yPosition );
+
+ // When the cursor position is changing, delay cursor blinking
+ mEventData->mDecorator->DelayCursorBlink();
}
else
{
}
}
+ if( mImpl->mEventData &&
+ 0 != events.size() )
+ {
+ // When the text is being modified, delay cursor blinking
+ mImpl->mEventData->mDecorator->DelayCursorBlink();
+ }
+
// Discard temporary text
events.clear();
}
{
if( 1u == tapCount )
{
+ // This is to avoid unnecessary relayouts when tapping an empty text-field
+ bool relayoutNeeded( false );
+
if( mImpl->IsShowingRealText() &&
EventData::EDITING == mImpl->mEventData->mState )
{
+ // Show grab handle on second tap
mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
+ relayoutNeeded = true;
}
- else if( EventData::EDITING_WITH_GRAB_HANDLE != mImpl->mEventData->mState )
+ else if( EventData::EDITING != mImpl->mEventData->mState &&
+ EventData::EDITING_WITH_GRAB_HANDLE != mImpl->mEventData->mState )
{
- // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
+ // Show cursor on first tap
mImpl->ChangeState( EventData::EDITING );
+ relayoutNeeded = true;
+ }
+ else if( mImpl->IsShowingRealText() )
+ {
+ // Move the cursor
+ relayoutNeeded = true;
}
- Event event( Event::TAP_EVENT );
- event.p1.mUint = tapCount;
- event.p2.mFloat = x;
- event.p3.mFloat = y;
- mImpl->mEventData->mEventQueue.push_back( event );
+ // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
+ if( relayoutNeeded )
+ {
+ Event event( Event::TAP_EVENT );
+ event.p1.mUint = tapCount;
+ event.p2.mFloat = x;
+ event.p3.mFloat = y;
+ mImpl->mEventData->mEventQueue.push_back( event );
- mImpl->RequestRelayout();
+ mImpl->RequestRelayout();
+ }
}
else if( 2u == tapCount )
{