Using Completed event for "ImeAction.Search"

I've successfully created a custom renderer "SearchEntry" to enable the "Search" button on the keyboard for this entry.
I'm also using the Completed event on the entry. On iOS this event gets fired, but not on Android.
When I look into the code of the EntryRenderer on Android, the Completed will not be fired when the ImeAction is "Search", see:
bool TextView.IOnEditorActionListener.OnEditorAction (TextView v, ImeAction actionId, KeyEvent e) { if (actionId == ImeAction.Done || (actionId == ImeAction.ImeNull && e.KeyCode == Keycode.Enter)) { base.Control.ClearFocus (); v.HideKeyboard (false); base.Element.SendCompleted (); } return true; }
Is there a way to also make sure the Completed event gets fired when using the Search ImeAction?


Best Answer


  • TheosTheos NLBeta ✭✭

    Thanks for the Custom Renderer code!
    I've added a BindableProperty to my custom control. Will provide that code so maybe you could use it too. As I don't like to use that event in my UI code :smile:


    public class SearchEntry : Entry
        #region Fields
        public static BindableProperty CompletedCommandProperty = BindableProperty.Create<SearchEntry, Command> (o => o.CompletedCommand, null);
        public static BindableProperty CompletedCommandPropertyParameter = BindableProperty.Create<SearchEntry, object> (o => o.CompletedCommandParameter, null);
        public SearchEntry ()
            Completed += delegate {
                if (CompletedCommand != null && CompletedCommand.CanExecute(CompletedCommandParameter))
        #region Properties
        public Command CompletedCommand
            get { return (Command)GetValue (CompletedCommandProperty); }
            set { SetValue (CompletedCommandProperty, value); }
        public object CompletedCommandParameter
            get { return GetValue (CompletedCommandPropertyParameter); }
            set { SetValue(CompletedCommandPropertyParameter, value); }


  • JacobPoulsen_JacobPoulsen_ DKMember ✭✭✭

    Glad it worked. You came up with a good solution, good luck!

  • LeonardHarrisLeonardHarris USMember
    edited September 2016

    How did you get the iOS event fired? Im using the EditorAction for the android as well but what event fires for iOS?
    I have something like this for iOS already :

    Control.EditingDidEnd += (object sender, EventArgs e) => { { entry.Unfocus(); // Some other code... }; };

Sign In or Register to comment.