mUpdateCursorPosition( false ),
mUpdateLeftSelectionPosition( false ),
mUpdateRightSelectionPosition( false ),
- mScrollAfterUpdateCursorPosition( false )
+ mScrollAfterUpdateCursorPosition( false ),
+ mScrollAfterDelete( false )
{}
EventData::~EventData()
mEventData->mDecoratorUpdated = true;
mEventData->mUpdateCursorPosition = false;
}
+ else if( mEventData->mScrollAfterDelete )
+ {
+ ScrollTextToMatchCursor();
+ mEventData->mDecoratorUpdated = true;
+ mEventData->mScrollAfterDelete = false;
+ }
else if( mEventData->mUpdateLeftSelectionPosition )
{
UpdateSelectionHandle( LEFT_SELECTION_HANDLE );
// TODO : calculate the vertical scroll.
}
+void Controller::Impl::ScrollTextToMatchCursor()
+{
+ // Get the current cursor position in decorator coords.
+ const Vector2& currentCursorPosition = mEventData->mDecorator->GetPosition( PRIMARY_CURSOR );
+
+ // Calculate the new cursor position.
+ CursorInfo cursorInfo;
+ GetCursorPosition( mEventData->mPrimaryCursorPosition,
+ cursorInfo );
+
+ // Calculate the offset to match the cursor position before the character was deleted.
+ mEventData->mScrollPosition.x = currentCursorPosition.x - cursorInfo.primaryPosition.x - mAlignmentOffset.x;
+
+ ClampHorizontalScroll( mVisualModel->GetActualSize() );
+ bool updateCursorPosition = true;
+
+ const Vector2 offset = mEventData->mScrollPosition + mAlignmentOffset;
+ const Vector2 cursorPosition = cursorInfo.primaryPosition + offset;
+
+ if( updateCursorPosition )
+ {
+ // Sets the cursor position.
+ mEventData->mDecorator->SetPosition( PRIMARY_CURSOR,
+ cursorPosition.x,
+ cursorPosition.y,
+ cursorInfo.primaryCursorHeight,
+ cursorInfo.lineHeight );
+
+ // Sets the grab handle position.
+ mEventData->mDecorator->SetPosition( GRAB_HANDLE,
+ cursorPosition.x,
+ cursorPosition.y,
+ cursorInfo.lineHeight );
+
+ if( cursorInfo.isSecondaryCursor )
+ {
+ mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_BOTH );
+ mEventData->mDecorator->SetPosition( SECONDARY_CURSOR,
+ cursorInfo.secondaryPosition.x + offset.x,
+ cursorInfo.secondaryPosition.y + offset.y,
+ cursorInfo.secondaryCursorHeight,
+ cursorInfo.lineHeight );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Secondary cursor position: %f,%f\n", cursorInfo.secondaryPosition.x + offset.x, cursorInfo.secondaryPosition.y + offset.y );
+ }
+ else
+ {
+ mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
+ }
+ }
+}
+
void Controller::Impl::RequestRelayout()
{
mControlInterface.RequestTextRelayout();
bool mUpdateLeftSelectionPosition : 1; ///< True if the visual position of the left selection handle must be recalculated.
bool mUpdateRightSelectionPosition : 1; ///< True if the visual position of the right selection handle must be recalculated.
bool mScrollAfterUpdateCursorPosition : 1; ///< Whether to scroll after the cursor position is updated.
+ bool mScrollAfterDelete : 1; ///< Whether to scroll after delete characters.
};
struct ModifyEvent
/**
* @brief Scrolls the text to make the cursor visible.
*
- * This method is called after inserting, deleting or moving the cursor with the keypad.
+ * This method is called after inserting text or moving the cursor with the keypad.
*/
void ScrollToMakeCursorVisible();
+ /**
+ * @brief Scrolls the text to make the cursor visible.
+ *
+ * This method is called after deleting text.
+ */
+ void ScrollTextToMatchCursor();
+
ControlInterface& mControlInterface; ///< Reference to the text controller.
LogicalModelPtr mLogicalModel; ///< Pointer to the logical model.
VisualModelPtr mVisualModel; ///< Pointer to the visual model.
REORDER );
// Queue a cursor reposition event; this must wait until after DoRelayout()
- mImpl->mEventData->mUpdateCursorPosition = true;
- mImpl->mEventData->mScrollAfterUpdateCursorPosition = true;
+ mImpl->mEventData->mScrollAfterDelete = true;
}
bool Controller::DoRelayout( const Size& size,
int keyCode = keyEvent.keyCode;
const std::string& keyString = keyEvent.keyPressed;
+ // Hide the grab handle.
+ mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
+
// Pre-process to separate modifying events from non-modifying input events.
if( Dali::DALI_KEY_ESCAPE == keyCode )
{