From 295e3b7b5077a19cea96b4b29a22ff99df1f16f9 Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Fri, 29 Dec 2023 14:49:36 +0900 Subject: [PATCH] Fix cursor position issue This patch fixes an issue where the cursor position is incorrectly positioned when padding is set for the textfield text editor. It is a problem caused by the wrong location of the cursor layer. Change-Id: Ifa0e9b752160761dfd6806cfc18dbf98576c71e3 Signed-off-by: Bowon Ryu --- dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp | 4 +++- dali-toolkit/internal/controls/text-controls/text-field-impl.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp index a9d5c2b..4f4b709 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -758,7 +758,9 @@ void TextEditor::OnRelayout(const Vector2& size, RelayoutContainer& container) } if(mCursorLayer) { - mCursorLayer.SetProperty(Actor::Property::POSITION, Vector2(padding.start, padding.top)); + // The cursor layer is added to the stencil in RenderText. + // Do not calculate the position because the stencil has already been resized excluding the padding size. + // There is no case where the text editor does not have a stencil. ResizeActor(mCursorLayer, contentSize); } diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index 7ef5425..88919fe 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -666,7 +666,12 @@ void TextField::OnRelayout(const Vector2& size, RelayoutContainer& container) } if(mCursorLayer) { - mCursorLayer.SetProperty(Actor::Property::POSITION, Vector2(padding.start, padding.top)); + if(!mStencil) + { + // If there is a stencil, the cursor layer is added to the stencil in RenderText. + // Do not calculate the position because the stencil has already been resized excluding the padding size. + mCursorLayer.SetProperty(Actor::Property::POSITION, Vector2(padding.start, padding.top)); + } ResizeActor(mCursorLayer, contentSize); } -- 2.7.4