GetCursorPosition( mEventData->mPrimaryCursorPosition,
cursorInfo );
- if( mEventData->mScrollAfterUpdatePosition )
+ // Scroll first the text after delete ...
+ if( mEventData->mScrollAfterDelete )
{
- ScrollToMakePositionVisible( cursorInfo.primaryPosition );
- mEventData->mScrollAfterUpdatePosition = false;
+ ScrollTextToMatchCursor( cursorInfo );
}
- else if( mEventData->mScrollAfterDelete )
+
+ // ... then, text can be scrolled to make the cursor visible.
+ if( mEventData->mScrollAfterUpdatePosition )
{
- ScrollTextToMatchCursor( cursorInfo );
- mEventData->mScrollAfterDelete = false;
+ ScrollToMakePositionVisible( cursorInfo.primaryPosition );
}
+ mEventData->mScrollAfterUpdatePosition = false;
+ mEventData->mScrollAfterDelete = false;
UpdateCursorPosition( cursorInfo );
mEventData->mUpdateLeftSelectionPosition = true;
mEventData->mUpdateRightSelectionPosition = true;
+ mEventData->mUpdateCursorPosition = false;
mEventData->mScrollAfterUpdatePosition = ( mEventData->mLeftSelectionPosition != mEventData->mRightSelectionPosition );
}
// Scroll after delete.
mEventData->mPrimaryCursorPosition = handlesCrossed ? mEventData->mRightSelectionPosition : mEventData->mLeftSelectionPosition;
- mEventData->mScrollAfterDelete = true;
}
- // Udpade the cursor position and the decorator.
- // Scroll after the position is updated if is not scrolling after delete.
- mEventData->mUpdateCursorPosition = true;
- mEventData->mScrollAfterUpdatePosition = !mEventData->mScrollAfterDelete;
mEventData->mDecoratorUpdated = true;
}
}
void Controller::Impl::ScrollToMakePositionVisible( const Vector2& position )
{
+ const float cursorWidth = mEventData->mDecorator ? mEventData->mDecorator->GetCursorWidth() : 0.f;
+
// position is in actor's coords.
- const float positionEnd = position.x + ( mEventData->mDecorator ? mEventData->mDecorator->GetCursorWidth() : 0.f );
+ const float positionEnd = position.x + cursorWidth;
// Transform the position to decorator coords.
const float alignment = IsShowingRealText() ? mAlignmentOffset.x : 0.f;
mEventData->mScrollPosition.x = currentCursorPosition.x - cursorInfo.primaryPosition.x - mAlignmentOffset.x;
ClampHorizontalScroll( mVisualModel->GetLayoutSize() );
+
+ // Makes the new cursor position visible if needed.
+ ScrollToMakePositionVisible( cursorInfo.primaryPosition );
}
void Controller::Impl::RequestRelayout()