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.KeyPress += (sender, keyEventArgs) => { if (keyEventArgs?.Event?.KeyCode == Keycode.Enter && keyEventArgs?.Event?.Action == KeyEventActions.Up) { customEntry.ReturnCommand?.Execute(null); } keyEventArgs.Handled = false; }; Control.EditorAction += (object sender, TextView.EditorActionEventArgs args) => { if (args?.Event?.KeyCode == Keycode.Enter) { return; } customEntry.ReturnCommand?.Execute(null); }; } }
void SetKeyboardReturnButton() { if (Element is Entry entry && Control is FormsEditText customControl) { customControl.ImeOptions = KeyboardHelpers.GetKeyboardButtonType(CustomReturnEffect.GetReturnType(entry)); customControl.EditorAction += HandleEditorAction; customControl.KeyPress += HandleKeyPress; } }
/// <summary> /// Triggered when the Element Property changes /// </summary> /// <param name="sender">object</param> /// <param name="e">PropertyChangedEventArgs</param> protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName.Equals(CustomReturnEntry.ReturnTypeProperty.PropertyName)) { if (Control != null && sender is CustomReturnEntry customEntry) { Control.ImeOptions = KeyboardHelpers.GetKeyboardButtonType(customEntry.ReturnType); } } }
void SetKeyboardReturnButton() { var customControl = Control as EntryEditText; var entry = Element as Entry; if (customControl != null && entry != null) { customControl.ImeOptions = KeyboardHelpers.GetKeyboardButtonType(ReturnTypeEffect.GetReturnType(entry)); customControl.EditorAction += HandleEditorAction; } }
void UnsetKeyboardReturnButton() { try { if (Control is FormsEditText formsEditText) { formsEditText.ImeOptions = KeyboardHelpers.GetKeyboardButtonType(ReturnType.Default); formsEditText.EditorAction -= HandleEditorAction; formsEditText.KeyPress -= HandleKeyPress; } } catch (ObjectDisposedException e) { Debug.WriteLine(e); } }
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.EditorAction += (object sender, TextView.EditorActionEventArgs args) => { customEntry?.ReturnCommand?.Execute(null); }; } }
void UnsetKeyboardReturnButton() { var customControl = Control as EntryEditText; try { if (customControl != null) { customControl.ImeOptions = KeyboardHelpers.GetKeyboardButtonType(ReturnType.Default); customControl.EditorAction -= HandleEditorAction; } } catch (ObjectDisposedException e) { Debug.WriteLine(e); } }
void UnsetKeyboardReturnButton() { var customControl = Control as FormsEditText; try { switch (Control) { case FormsEditText formsEditText: formsEditText.ImeOptions = KeyboardHelpers.GetKeyboardButtonType(ReturnType.Default); formsEditText.EditorAction -= HandleEditorAction; formsEditText.KeyPress -= HandleKeyPress; break; } } catch (ObjectDisposedException e) { Debug.WriteLine(e); } }
/// <summary> /// Triggered when the Element changes /// </summary> /// <param name="e">ElementChangedEventArgs</param> protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (Control != null && Element is CustomReturnEntry customEntry) { Control.ImeOptions = KeyboardHelpers.GetKeyboardButtonType(customEntry.ReturnType); Control.KeyPress += HandleControlKeyPress; Control.EditorAction += (object sender, TextView.EditorActionEventArgs args) => { if (args?.Event?.KeyCode is Keycode.Enter) { return; } ExecuteCommand(customEntry); }; } }