forked from xamarin/Xamarin.Forms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaterialFormsEditText.cs
65 lines (53 loc) · 1.68 KB
/
MaterialFormsEditText.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#if __ANDROID_28__
using System;
using Android.Content;
using Android.Views;
using Android.Runtime;
using Android.Util;
using Xamarin.Forms.Platform.Android;
namespace Xamarin.Forms.Material.Android
{
public class MaterialFormsEditText : MaterialFormsEditTextBase, IFormsEditText
{
public MaterialFormsEditText(Context context) : base(context)
{
}
protected MaterialFormsEditText(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
{
}
public MaterialFormsEditText(Context context, IAttributeSet attrs) : base(context, attrs)
{
}
public MaterialFormsEditText(Context context, IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr)
{
}
public override bool OnKeyPreIme(Keycode keyCode, KeyEvent e)
{
if (keyCode != Keycode.Back || e.Action != KeyEventActions.Down)
{
return base.OnKeyPreIme(keyCode, e);
}
this.HideKeyboard();
_onKeyboardBackPressed?.Invoke(this, EventArgs.Empty);
return true;
}
event EventHandler _onKeyboardBackPressed;
event EventHandler IFormsEditText.OnKeyboardBackPressed
{
add => _onKeyboardBackPressed += value;
remove => _onKeyboardBackPressed -= value;
}
event EventHandler<Platform.Android.SelectionChangedEventArgs> _selectionChanged;
event EventHandler<Platform.Android.SelectionChangedEventArgs> IFormsEditText.SelectionChanged
{
add => _selectionChanged += value;
remove => _selectionChanged -= value;
}
protected override void OnSelectionChanged(int selStart, int selEnd)
{
base.OnSelectionChanged(selStart, selEnd);
_selectionChanged?.Invoke(this, new Platform.Android.SelectionChangedEventArgs(selStart, selEnd));
}
}
}
#endif