0

I want the next arrow key to say 'Done' when the Editor field is highlighted.

Here,In the image the Marked key 'Next arrow key' has to "Done"

I have Referred some Links Regarding this but none seems to work in my case...This is one such Change return to be next/done key in Xamarin Forms Shared Project

Here,They are extending Entry property where as in my case I have to extend the Editor property when I try to extend the Editor Property it shows no errors but the keypad is looking as before

My code is,

public class PlaceholderEditorRenderer : EditorRenderer
{
    public PlaceholderEditorRenderer()
    {
    }

    protected override void OnElementChanged(
        ElementChangedEventArgs<Editor> e)
    {
        base.OnElementChanged(e);

        PlaceholderEditor placeHolderEditor = (PlaceholderEditor)this.Element;

        if (this.Control != null)
        {
            if (placeHolderEditor != null)
            {
                SetReturnType(placeHolderEditor);

                Control.EditorAction += (object sender, EditText.EditorActionEventArgs args) =>
                {
                    if (placeHolderEditor.ReturnKeyType == ReturnKeyTypes.Done)
                        placeHolderEditor.Unfocus();

                    // Call all the methods attached to custom_entry event handler Completed
                    placeHolderEditor.InvokeCompleted();
                };
            }
        }

        if (e.NewElement != null)
        {
            var element = e.NewElement as PlaceholderEditor;
            this.Control.Hint = element.Placeholder;
        }
    }

    protected override void OnElementPropertyChanged(
        object sender,
        PropertyChangedEventArgs e)
    {
        base.OnElementPropertyChanged(sender, e);

        if (e.PropertyName == PlaceholderEditor.PlaceholderProperty.PropertyName)
        {
            var element = this.Element as PlaceholderEditor;
            this.Control.Hint = element.Placeholder;
        }
    }

    private void SetReturnType(PlaceholderEditor entry)
    {
        ReturnKeyTypes type = entry.ReturnKeyType;

        switch (type)
        {
            case ReturnKeyTypes.Go:
                Control.ImeOptions = ImeAction.Go;
                Control.SetImeActionLabel("Go", ImeAction.Go);
                break;
            case ReturnKeyTypes.Next:
                Control.ImeOptions = ImeAction.Next;
                Control.SetImeActionLabel("Next", ImeAction.Next);
                break;
            case ReturnKeyTypes.Send:
                Control.ImeOptions = ImeAction.Send;
                Control.SetImeActionLabel("Send", ImeAction.Send);
                break;
            case ReturnKeyTypes.Search:
                Control.ImeOptions = ImeAction.Search;
                Control.SetImeActionLabel("Search", ImeAction.Search);
                break;
            case ReturnKeyTypes.Done:
                Control.ImeOptions = ImeAction.Done;
                Control.SetImeActionLabel("Done", ImeAction.Done);
                break;
            default:
                Control.ImeOptions = ImeAction.Done;
                Control.SetImeActionLabel("Done", ImeAction.Done);
                break;
        }
    }
}
Mounika
  • 137
  • 2
  • 11
  • Did you try the new Xamarin Forms [Return Type](https://learn.microsoft.com/en-us/dotnet/api/xamarin.forms.returntype?view=xamarin-forms) ? – FabriBertani Oct 11 '18 at 19:25
  • Yeah...I tried that . Return Type="Done" I passed it like this in my xaml code and Enum types I declared the options....Done,Go,Serach – Mounika Oct 12 '18 at 03:35

0 Answers0