Skip to content

Commit

Permalink
[Tizen] Fix entry cursor issue (dotnet#222)
Browse files Browse the repository at this point in the history
* Fix entry cursor issue

* Fix UpdateSelectionLength method
  • Loading branch information
shyunMin authored and rookiejava committed Jan 21, 2022
1 parent b795587 commit d08a7f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using Tizen.UIExtensions.ElmSharp;
using SmartEvent = ElmSharp.SmartEvent;
using EEntry = ElmSharp.Entry;

namespace Microsoft.Maui.Handlers
Expand All @@ -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)
Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/Core/src/Platform/Tizen/EntryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit d08a7f6

Please sign in to comment.