protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName == CustomReturnEntry.ReturnTypeProperty.PropertyName) { var customEntry = sender as CustomReturnEntry; if (Control != null && customEntry != null) { Control.ImeOptions = KeyboardHelpers.GetKeyboardButtonType(customEntry.ReturnType); } } else if (e.PropertyName == CustomReturnEntry.SelectAllOnFocusProperty.PropertyName) { var customEntry = sender as CustomReturnEntry; if (Control != null && customEntry != null) { Control.SetSelectAllOnFocus(customEntry.SelectAllOnFocus); } } else if (e.PropertyName == CustomReturnEntry.ErrorMessageProperty.PropertyName) { var customEntry = sender as CustomReturnEntry; if (Control != null && customEntry != null) { var icon = this.Context.GetDrawable(Resource.Drawable.entry_error_hint); icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight); Control.SetError(customEntry.ErrorMessage, icon); } } }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); var customEntry = Element as CustomReturnEntry; if (Control != null && customEntry != null) { Control.ImeOptions = KeyboardHelpers.GetKeyboardButtonType(customEntry.ReturnType); //Control.FocusChange += (sender, args) => //{ // if (args.HasFocus) // { // if (!string.IsNullOrEmpty(Control.Text)) // { // Control.SetSelection(Control.Text.Length); // } // } //}; //Control.FocusChange += Control_FocusChange; Control.EditorAction += Control_EditorAction; //Control.EditorAction += (object sender, TextView.EditorActionEventArgs args) => //{ // if (args?.Event?.KeyCode == Keycode.Enter) // return; // var dtNow = DateTime.Now; // bool shouldTriggerEvent = false; // if(_lastEnterKeyPressed == null) // { // shouldTriggerEvent = true; // } // else // { // TimeSpan ts = dtNow - _lastEnterKeyPressed.Value; // if(ts.TotalMilliseconds > 100) // { // shouldTriggerEvent = true; // } // } // _lastEnterKeyPressed = dtNow; // if (shouldTriggerEvent) // { // customEntry.ReturnCommand?.Execute(null); // customEntry.OnRetrunKeyPress(); // } //}; } }