Skip to content

Commit

Permalink
Merge branch 'show-keyboard-on-android-focus' of github.com:dotnet/ma…
Browse files Browse the repository at this point in the history
…ui into show-keyboard-on-android-focus
  • Loading branch information
rachelkang committed Feb 7, 2023
2 parents 09ed458 + 4b5a3a5 commit e7464bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Core/src/Handlers/Editor/EditorHandler.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ protected override void ConnectHandler(AppCompatEditText platformView)
{
platformView.ViewAttachedToWindow += OnPlatformViewAttachedToWindow;
platformView.TextChanged += OnTextChanged;
platformView.FocusChange += OnFocusedChange;
}

// TODO: NET8 issoto - Change the platformView type to MauiAppCompatEditText
protected override void DisconnectHandler(AppCompatEditText platformView)
{
platformView.ViewAttachedToWindow -= OnPlatformViewAttachedToWindow;
platformView.TextChanged -= OnTextChanged;
platformView.FocusChange -= OnFocusedChange;

// TODO: NET8 issoto - Remove the casting once we can set the TPlatformView generic type as MauiAppCompatEditText
if (_set && platformView is MauiAppCompatEditText editText)
Expand Down Expand Up @@ -151,5 +153,13 @@ public override void PlatformArrange(Rect frame)
this.PrepareForTextViewArrange(frame);
base.PlatformArrange(frame);
}

void OnFocusedChange(object? sender, FocusChangeEventArgs e)
{
if (VirtualView == null)
return;

KeyboardManager.ShowKeyboard(PlatformView);
}
}
}
2 changes: 2 additions & 0 deletions src/Core/src/Handlers/Entry/EntryHandler.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ void OnFocusedChange(object? sender, FocusChangeEventArgs e)
}

MapClearButtonVisibility(this, VirtualView);

KeyboardManager.ShowKeyboard(PlatformView);
}

// Check whether the touched position inbounds with clear button.
Expand Down

0 comments on commit e7464bf

Please sign in to comment.