Hi all,
I'm trying to debug an interesting issue with Android. I have an issue in which my Entry
objects are giving up focus inconsistently when tapped. This is only happening when the Entry
object is embedded in a TableView
. The xaml I have is laid out below:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="KeyTest.SettingsPage"
xmlns:keytest="clr-namespace:KeyTest;assembly=KeyTest">
<ContentPage.Content>
<TableView Intent="Form" HasUnevenRows="true" x:Name="tableView">
<TableView.Root>
<TableSection Title="General" x:Name="tableSection">
<ViewCell x:Name="viewCell">
<keytest:MyNewEntry x:Name="myedit" Placeholder="Some Text"/>
</ViewCell>
</TableSection>
</TableView.Root>
</TableView>
</ContentPage.Content>
</ContentPage>
To debug this, I'm trying to create a custom renderer in Android and override the OnFocusRequested (object sender, VisualElement.FocusRequestArgs e)
method. Unfortunately, this doesn't compile due to the protection level of FocusRequestArgs
.
public MyNewEntryRenderer ()
{
}
public override void ClearFocus ()
{
Log.Info ("MyNewEntryRenderer", "Clear focus called");
base.ClearFocus ();
}
protected override void OnFocusChangeRequested (object sender, VisualElement.FocusRequestArgs e)
{
base.OnFocusChangeRequested (sender, e);
}
This seems like a bug in Xamarin.Forms as I should be able to override any protected method and I cannot as VisualElement.FocusRequestArgs
is an internal class.
Note that this focus issue happens only when I've got AppCompat enabled using https://github.com/nativecode-dev/oss-xamarin. I believe I may be able to fix the issue if I can narrow down what view is stealing focus and what views are orphaning keyboards. What's the best way to debug this?
Thanks!