Cannot focus when ShowButtons is false

2 posts, 0 answers
  1. Andrew
    Andrew avatar
    24 posts
    Member since:
    Dec 2010

    Posted 30 Oct 2012 Link to this post

    We just upgraded from 2012 Q1 to 2012 Q3, and we found that we could no longer click in the TextBox portion of the control to enter text, unless we clicked the up or down button first. This is particularly problematic when ShowButtons is set to false, because it renders the control unfocusable and unusable.

    Using JustDecompile, I determined that RadNumericUpDown's OnApplyTemplate method seems to have been changed.

    Here’s the Q1 version:

    public override void OnApplyTemplate()

    {

        base.OnApplyTemplate();

        …

        if (this.textBox != null)

        {

            this.textBox.TextChanged += OnTextBoxTextChanged;

            this.textBox.IsReadOnly = false;

        }

        …

    }

    Here’s the Q3 version:

    public override void OnApplyTemplate()

    {

        base.OnApplyTemplate();

        …

        if (this.textBox != null)

        {

            this.textBox.TextChanged += OnTextBoxTextChanged;

            Binding binding = new Binding("IsFocused");

            binding.Source = this;

            this.textBox.SetBinding(UIElement.IsHitTestVisibleProperty, binding);

            this.textBox.IsReadOnly = false;

        }

        …

    }



    I solved the problem by overriding OnApplyTemplate in a subclass of RadNumericUpDown, and setting the TextBox's IsHitTestVisible back to true.

    Can anyone comment on why this change was made to RadNumericUpDown? Thanks!

    UPDATE: Feel free to disregard this question. The issue was caused by an omission in our ControlTemplate for RadNumericUpDown. For some reason, it did not include the elements named Background or DisabledVisual. Adding the Background element fixed the problem without having to set IsHitTestVisible in OnApplyTemplate, because the Background element is hit test visible.
  2. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 02 Nov 2012 Link to this post

    Hi Andrew,

    We made some changes in order to improve the TextBox behavior. Now it should properly select the whole text on getting focus and selecting a specific digits with the mouse should be more intuitive. But our changes should not affect the behavior you mentioned.

    I am glad that you managed to found the problem and fix it.

    All the best,
    Boyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top