Initial text selected

6 posts, 0 answers
  1. Florent
    Florent avatar
    9 posts
    Member since:
    May 2013

    Posted 20 Sep 2013 Link to this post

    Hello,

    I created an InputPrompt and choosed an initial text  by using Style / InputPrompSettings class and settings the RadTextBox.TextProperty

    But, there is 2 issues. The cursor stay at the begin of the RadTextBox and the initial text is not selected so I can change it only by pressing one letter on keyboard.

    Is there a way to achieve it ?

    Thanks for your answer.

    Regards,
    Florent
  2. MasterChiefMasterChef
    MasterChiefMasterChef avatar
    152 posts
    Member since:
    Jan 2013

    Posted 23 Sep 2013 Link to this post

    Hi Florent,

    If you are trying to clear out the text in the InputPrompt when the user clicks on it, you should write an event handler for the GotFocus event.

    The markup would define a name and an event handler:

    <Controls:RadTextBox Name="telerikInput" Text="enter text here..." GotFocus="inputGotFocus" />

    And the event in the code behind will clear the text in the InputPrompt:

    private void inputGotFocus(object sender, RoutedEventArgs e)
    {
        telerikInput.Text = "";
    }


    Good luck,
    Master Chief
  3. DevCraft banner
  4. Todor
    Admin
    Todor avatar
    778 posts

    Posted 24 Sep 2013 Link to this post

    Hello Florent,

    I'm not sure I understand correctly your desired behavior, but it sound like it would be best if you set the Watermark property through Style. This way, when you start typing the initial value will be cleared. If you want to keep using the Text Property, you will not be able to move the cursor's position, but the text can again be easily cleared, this time with the Clear Button that is part of the text box.

    I hope this information helps.
     
    Regards,
    Todor
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  5. Florent
    Florent avatar
    9 posts
    Member since:
    May 2013

    Posted 24 Sep 2013 Link to this post

    No, my need is to select the initial text so I can choose to override it only by typing one letter. Same behaviour as when you create a new folder on Windows, where you can choose to rename it instead of keeping the name "New folder".

    Sure, users can still use the erase button and start to type, but it is just common ergonomy to allow it in a more usual and quickest way.
  6. Todor
    Admin
    Todor avatar
    778 posts

    Posted 25 Sep 2013 Link to this post

    Hi Florent,

    Thank you for getting back to us.

    The initial selection is not possible in RadInputPrompt. It visualizes an instance of RadTextBox, which inherits from the native TextBox control. The selection is provided by the native control by the properties SelectedText, SelectionStart, SelectionLength. However, since none of them is a dependency property they can't be set through style.
     
    Regards,
    Todor
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  7. Todor
    Admin
    Todor avatar
    778 posts

    Posted 13 Dec 2013 Link to this post

    Hello Florent,

    I just wanted to let you know about a possible workaround for your scenario in case you still need to add initial selection in RadInputPrompt. You can find the sample project as an attachment to this post.

    Let us know if you need further assistance.

    Regards,
    Todor
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Back to Top
DevCraft banner