maui-linux/Xamarin.Forms.Platform.Android/Renderers/EntryEditText.cs

42 строки
1.2 KiB
C#

using System;
using Android.Content;
using Android.Graphics;
using Android.Views;
using Android.Widget;
namespace Xamarin.Forms.Platform.Android
{
public class EntryEditText : EditText, IDescendantFocusToggler
{
DescendantFocusToggler _descendantFocusToggler;
internal EntryEditText(Context context) : base(context)
{
}
bool IDescendantFocusToggler.RequestFocus(global::Android.Views.View control, Func<bool> baseRequestFocus)
{
_descendantFocusToggler = _descendantFocusToggler ?? new DescendantFocusToggler();
return _descendantFocusToggler.RequestFocus(control, baseRequestFocus);
}
public override bool OnKeyPreIme(Keycode keyCode, KeyEvent e)
{
if (keyCode == Keycode.Back && e.Action == KeyEventActions.Down)
{
EventHandler handler = OnKeyboardBackPressed;
if (handler != null)
handler(this, EventArgs.Empty);
}
return base.OnKeyPreIme(keyCode, e);
}
public override bool RequestFocus(FocusSearchDirection direction, Rect previouslyFocusedRect)
{
return (this as IDescendantFocusToggler).RequestFocus(this, () => base.RequestFocus(direction, previouslyFocusedRect));
}
internal event EventHandler OnKeyboardBackPressed;
}
}