This is a migrated thread and some comments may be shown as answers.

Cannot focus when ShowButtons is false

1 Answer 56 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andrew
Top achievements
Rank 1
Andrew asked on 30 Oct 2012, 03:55 PM
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.

1 Answer, 1 is accepted

Sort by
0
Boyan
Telerik team
answered on 02 Nov 2012, 12:39 PM
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.

Tags
NumericUpDown
Asked by
Andrew
Top achievements
Rank 1
Answers by
Boyan
Telerik team
Share this question
or