From b2f23c6baad7f762350db0b76d35d612a8306f69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AF=BC=EC=84=B1=ED=98=84/Common=20Platform=20Lab=28SR?= =?UTF-8?q?=29/Staff=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Wed, 3 Nov 2021 16:01:37 +0900 Subject: [PATCH] [Tizen] Fix entry cursor issue (#222) * Fix entry cursor issue * Fix UpdateSelectionLength method --- src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs | 12 +++++------- src/Core/src/Platform/Tizen/EntryExtensions.cs | 3 +++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs b/src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs index bc91c738cc6f..3542e2586993 100644 --- a/src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs +++ b/src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs @@ -1,6 +1,5 @@ using System; using Tizen.UIExtensions.ElmSharp; -using SmartEvent = ElmSharp.SmartEvent; using EEntry = ElmSharp.Entry; namespace Microsoft.Maui.Handlers @@ -21,19 +20,18 @@ protected override Entry CreateNativeView() protected override void ConnectHandler(Entry nativeView) { nativeView.Activated += OnCompleted; - nativeView.CursorChanged += OnCursorChanged; + nativeView.CursorPositionChanged += OnCursorChanged; - // In order to know when the selection is cleared, "selecton,cleared" event has been used. + // In order to know when the selection is cleared, SelectionCleared event has been used. // Because CursorChanged event is still invoked with the selected text when an user clears selection. It is an known issue in EFL. - SmartEvent selectionCleared = new SmartEvent(nativeView, nativeView.RealHandle, ThemeConstants.Entry.Signals.SelectionCleared); - selectionCleared.On += OnSelectionCleared; + nativeView.SelectionCleared += OnSelectionCleared; nativeView.TextChanged += OnTextChanged; nativeView.EntryLayoutFocused += OnFocused; nativeView.EntryLayoutUnfocused += OnUnfocused; - nativeView.PrependMarkUpFilter(MaxLengthFilter); + // TODO: Fix me later // An initial CursorPosition is set after layouting to avoid timing issue when the EditField entry is initialized. //if (VirtualView != null) @@ -48,7 +46,7 @@ protected override void ConnectHandler(Entry nativeView) protected override void DisconnectHandler(Entry nativeView) { nativeView.Activated -= OnCompleted; - nativeView.CursorChanged -= OnCursorChanged; + nativeView.CursorPositionChanged -= OnCursorChanged; nativeView.TextChanged -= OnTextChanged; nativeView.EntryLayoutFocused -= OnFocused; nativeView.EntryLayoutUnfocused -= OnUnfocused; diff --git a/src/Core/src/Platform/Tizen/EntryExtensions.cs b/src/Core/src/Platform/Tizen/EntryExtensions.cs index 1573ebd24c26..f7cf92fdcd07 100644 --- a/src/Core/src/Platform/Tizen/EntryExtensions.cs +++ b/src/Core/src/Platform/Tizen/EntryExtensions.cs @@ -102,6 +102,9 @@ public static void UpdateMaxLength(this Entry nativeEntry, ITextInput entry) [PortHandler] public static void UpdateSelectionLength(this Entry nativeEntry, IEntry entry) { + if (nativeEntry.IsUpdatingCursorPosition) + return; + int start = GetSelectionStart(nativeEntry, entry); int end = GetSelectionEnd(nativeEntry, entry, start);