InputScope search does not accept the "enter" button

5 posts, 1 answers
  1. Andrew
    Andrew avatar
    26 posts
    Member since:
    Sep 2011

    Posted 21 Sep 2012 Link to this post

    The virtual keyboard shows a white arrow that you can normally press to indicate action. However it does nothing. I would expect it to call the ActionButtonCommand. Am I doing anything wrong?

    <telerikPrimitives:RadTextBox Watermark="search" ActionButtonVisibility="Visible"
        ActionButtonCommand="{Binding DoSearchCommand}" InputScope="Search"  />
  2. Todor
    Admin
    Todor avatar
    778 posts

    Posted 21 Sep 2012 Link to this post

    Hello Robert,

    Thank you for your question.

    I assume that the arrow that you mean is the Enter key. Pressing it, however would not execute the ActionButtonCommand, because for some scenarios (for example multiple row text box) it might not be the desired behavior. You can easily implement this functionality by providing an event handler for the KeyDown or KeyUp events of RadTextBox and execute the associated command manually:
    private void textBox_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Key == Key.Enter)
        {
            ICommand command = textBox.ActionButtonCommand as ICommand;
            command.Execute(textBox.Text);
        }
    }

    I hope this information helps. Let me know if I can assist you further.

    Greetings,
    Todor
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  3. DevCraft banner
  4. Andrew
    Andrew avatar
    26 posts
    Member since:
    Sep 2011

    Posted 21 Sep 2012 Link to this post

    While your solution does work it requires so much more code and isn't elegant. For multi-row text box, isn't that what the AcceptsReturn property is for. I would think that you could read that property and if set to false you could handle the enter button correctly by calling the actionbuttoncommand.
  5. Answer
    Todor
    Admin
    Todor avatar
    778 posts

    Posted 24 Sep 2012 Link to this post

    Hi Robert,

    Thank you for your suggestion.

    We designed the ActionButton to be abstract enough so it might have a function which is not necessarily related to the Enter key. For example, in a "Add new contact" page, the enter key can be used for saving the new contact and the ActionButton in some of the fields might be for adding a photo. I agree that the scenario where you want the ActionButton to be executed when Enter key is pressed seems more common and this is why we decided to introduce a new property in RadTextBox that will allow you to choose whether you want to execute the ActionButtonCommand on Enter or not. The new property will be available with our next internal build.

    Let me know if you have other suggestions or questions regarding our controls.

    Greetings,
    Todor
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  6. Andrew
    Andrew avatar
    26 posts
    Member since:
    Sep 2011

    Posted 24 Sep 2012 Link to this post

    That's a better solution than my suggestion actually. Thanks.

    Robert
Back to Top
DevCraft banner