__pScrollEffect->previousY = -1.0f;
__pScrollEffect->currentY = -1.0f;
+ __pScrollEffect->previousX = -1.0f;
+ __pScrollEffect->currentX = -1.0f;
+ __pScrollEffect->cursorPosition = -1;
pEditModel = new (std::nothrow) _EditModel;
SysTryCatch(NID_UI_CTRL, pEditModel, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance");
__pScrollEffect->previousY = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().y);
__pScrollEffect->currentY = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().y);
+ __pScrollEffect->previousX = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().x);
+ __pScrollEffect->currentX = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().x);
+ __pScrollEffect->cursorPosition = GetCursorPosition();
FloatRectangle absoluteEditRect = __pEdit->GetAbsoluteBoundsF();
return true;
}
- int newIndex = -1;
- FloatRectangle fromBounds;
- FloatRectangle toBounds;
-
- CalculateCursorBounds(__textObjectBounds, fromBounds);
- newIndex = GetCursorPositionAt(touchInfo.GetCurrentPosition());
- if (newIndex != -1)
+ if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
{
- if (Math::Abs(newIndex - __cursorPos) > 3)
+ float horizontalGap = touchInfo.GetCurrentPosition().x - __pScrollEffect->currentX;
+ FloatDimension currentCharacterDimension;
+ int currentLineOffset = __pTextObject->GetTextOffsetAtLine(0);
+ int currentLineLength = __pTextObject->GetTextLengthAtLine(0);
+ if (horizontalGap < 0.0f && currentLineOffset+currentLineLength < GetTextLength())
{
- return true;
- }
-
- CalculateCursorBounds(__textObjectBounds, toBounds, newIndex);
- __isCursorChanged = true;
- SetCursorPosition(newIndex);
-
- __isMovingCursorByTouchMove = true;
- __isTouchReleaseSkipped = true;
-
- StopCursorTimer();
- MoveCursor(fromBounds, toBounds);
- __pEdit->Invalidate();
+ currentCharacterDimension = __pTextObject->GetTextExtentF(currentLineOffset+currentLineLength, 1);
+ if (Math::Abs(horizontalGap) >= currentCharacterDimension.width)
+ {
+ __pScrollEffect->previousX = __pScrollEffect->currentX;
+ __pScrollEffect->currentX = touchInfo.GetCurrentPosition().x;
+ __isMovingCursorByTouchMove = true;
+ __isTouchReleaseSkipped = true;
+ StopCursorTimer();
- return true;
- }
+ SetCursorPosition(currentLineOffset+currentLineLength+1);
+ UpdateComponentInformation();
- if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE || __pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
- {
- float horizontalGap = touchInfo.GetCurrentPosition().x - fromBounds.x;
- FloatDimension currentCharacterDimension;
- if (horizontalGap > 0.0f && __cursorPos < GetTextLength())
+ currentLineOffset = __pTextObject->GetTextOffsetAtLine(0);
+ if (__pScrollEffect->cursorPosition > currentLineOffset)
+ {
+ SetCursorPosition(__pScrollEffect->cursorPosition);
+ }
+ else
+ {
+ __pScrollEffect->cursorPosition = currentLineOffset + 1;
+ SetCursorPosition(__pScrollEffect->cursorPosition);
+ }
+ __pEdit->Invalidate();
+ return true;
+ }
+ }
+ if (horizontalGap > 0.0f && currentLineOffset > 0)
{
- currentCharacterDimension = __pTextObject->GetTextExtentF(__cursorPos, 1);
+ currentCharacterDimension = __pTextObject->GetTextExtentF(currentLineOffset-1, 1);
if (horizontalGap >= currentCharacterDimension.width)
{
- SetCursorPosition(__cursorPos+1);
+ __pScrollEffect->previousX = __pScrollEffect->currentX;
+ __pScrollEffect->currentX = touchInfo.GetCurrentPosition().x;
+ __isMovingCursorByTouchMove = true;
+ __isTouchReleaseSkipped = true;
+ StopCursorTimer();
+
+ SetCursorPosition(currentLineOffset);
+ UpdateComponentInformation();
+ currentLineOffset = __pTextObject->GetTextOffsetAtLine(0);
+ currentLineLength = __pTextObject->GetTextLengthAtLine(0);
+ if (__pScrollEffect->cursorPosition < currentLineOffset + currentLineLength)
+ {
+ SetCursorPosition(__pScrollEffect->cursorPosition);
+ }
+ else
+ {
+ __pScrollEffect->cursorPosition = currentLineOffset + currentLineLength;
+ SetCursorPosition(__pScrollEffect->cursorPosition);
+ }
__pEdit->Invalidate();
return true;
}
}
- if (horizontalGap < 0.0f && __cursorPos > 0)
+ }
+ else
+ {
+ int newIndex = -1;
+ FloatRectangle fromBounds;
+ FloatRectangle toBounds;
+ CalculateCursorBounds(__textObjectBounds, fromBounds);
+ newIndex = GetCursorPositionAt(touchInfo.GetCurrentPosition());
+ if (newIndex != -1)
{
- currentCharacterDimension = __pTextObject->GetTextExtentF(__cursorPos-1, 1);
- if (Math::Abs(horizontalGap) >= currentCharacterDimension.width)
+ if (Math::Abs(newIndex - __cursorPos) > 3)
{
- SetCursorPosition(__cursorPos-1);
- __pEdit->Invalidate();
return true;
}
+
+ CalculateCursorBounds(__textObjectBounds, toBounds, newIndex);
+ __isCursorChanged = true;
+ SetCursorPosition(newIndex);
+
+ __isMovingCursorByTouchMove = true;
+ __isTouchReleaseSkipped = true;
+
+ StopCursorTimer();
+ MoveCursor(fromBounds, toBounds);
+ __pEdit->Invalidate();
+
+ return true;
}
- }
+ if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
+ {
+ float horizontalGap = touchInfo.GetCurrentPosition().x - fromBounds.x;
+ FloatDimension currentCharacterDimension;
+ if (horizontalGap > 0.0f && __cursorPos < GetTextLength())
+ {
+ currentCharacterDimension = __pTextObject->GetTextExtentF(__cursorPos, 1);
+ if (horizontalGap >= currentCharacterDimension.width)
+ {
+ SetCursorPosition(__cursorPos+1);
+ __pEdit->Invalidate();
+ return true;
+ }
+ }
+ if (horizontalGap < 0.0f && __cursorPos > 0)
+ {
+ currentCharacterDimension = __pTextObject->GetTextExtentF(__cursorPos-1, 1);
+ if (Math::Abs(horizontalGap) >= currentCharacterDimension.width)
+ {
+ SetCursorPosition(__cursorPos-1);
+ __pEdit->Invalidate();
+ return true;
+ }
+ }
+ }
+ }
if (__isMovingCursorByTouchMove)
{
return true;