Focus on border clicked

3 posts, 0 answers
  1. Alex
    Alex avatar
    141 posts
    Member since:
    Mar 2010

    Posted 23 Sep 2014 Link to this post

    What is the best way to make this control focus when the border is clicked? I'm am noticing that the cursor is changed to the i-beam when the mouse hovers over the border of the control, but clicking does not focus on the control. 

    (Note, this behaviour is present in both the Masked input boxes, and the Auto complete boxes and I've duplicated the post in both forums)

    Version 2014.2.729.1050
  2. Alex
    Alex avatar
    141 posts
    Member since:
    Mar 2010

    Posted 23 Sep 2014 Link to this post

    To see this behaviour simply create a control with a large border
    e.g.

    <telerik:RadAutoCompleteBox SearchText="auto" BorderThickness="10"/>
    <telerik:RadMaskedCurrencyInput SelectionOnFocus="SelectAll" BorderThickness="10" />
    <telerik:RadMaskedDateTimeInput SelectionOnFocus="SelectAll" BorderThickness="10" />
    <telerik:RadMaskedNumericInput SelectionOnFocus="SelectAll" BorderThickness="10" />
    <telerik:RadMaskedTextInput SelectionOnFocus="SelectAll" BorderThickness="10" />
  3. DevCraft banner
  4. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 25 Sep 2014 Link to this post

    Hi Alex,

    What I can suggest you in order to achieve this particular scenario, would be to hook to the MouseLeftButtonDown event of the AutoCompleteBox. Inside of the handler you would be able to manually focus the control and in addition to this you can select the text inside by getting the WatermarkTextBox from the ControlTemplate of the AutoCompleteBox. Please check the following code snippet:

    private void Auto_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        var autoCompleteBox = sender as RadAutoCompleteBox;
        autoCompleteBox.Focus();
        var txtBox = autoCompleteBox.ChildrenOfType<RadWatermarkTextBox>().First();
        txtBox.SelectAll();
    }

    Hope this helps.

    Regards,
    Kalin
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top