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

RadNumericUpDown focus problems with its internal edit control

5 Answers 184 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 2
Iron
Iron
Veteran
Joe asked on 04 Dec 2018, 08:58 PM

I use RadNumericUpDown in many places.  My application runs on a PC and on the Microsoft Surface and uses the Windows8Touch theme.   

My problem is that whenever the user types the + or - button of a RadNumericUpDown on the MS Surface, the Window Virtual Keyboard appears, immediately obscuring the very control you are using.  The user isn't trying to edit the text box, mind you, just tapping the buttons.

I can see the cause:  Whenever you tap one of those buttons, the edit control gets keyboard focus.  This triggers Windows (at a very low level) to pop up the virtual keyboard.

But if the user is only tapping the buttons, it seems that the edit box should not get focus.  That should not happen until you actually try to *type* in it.   And even if you think it *should* get focus, there at least needs to be a way to prevent it from happening.  

Here is what I tried:

1. I tried to setting the entire RadNumericControl's IsEditable property to "False" but this has no effect.  Even though the user cannot edit the box, tapping the UP or DOWN button *still* makes the edit control think it is being edited enough to give it focus and force that virtual keyboard to appear

2. I tried setting the entire control's "Focusable" property to "False" but that didn't work either.  The internal edit control still gets keyboard focus.  This is because the Telerik template for the control fails to pass the "Focusable" to its internal edit through TemplateBinding. 

I have managed to "fix" this by copying the entire RadNumericUpDown control's template and making it pass "Focusable" to its internal edit via the TemplateBinding.  Then I use this template for my RadNumericUpDown and set them to not Focusable.

But I don't want to copy the entire template that because a)it's overkill and b) my copied template is not using the Telerik Windows8Touch theme that I applied to everything else.  So it looks out of place and terrible.  Yeah, maybe I can copy stuff from the Telerik XAML files but again, I'd really prefer a simple property on the RadNumericUpDown.

Am I missing some simpler method here?  Does RadNumericUpDown give me a way to get at the internal edit control and prevent it from getting keyboard focus short of copying its entire template? 

Also, am I correct that it's internal edit should NOT get keyboard focus if you just tap the buttons (at least if it's not editable)?

I am hoping you can point me to an easier way.  

 

5 Answers, 1 is accepted

Sort by
0
Joe
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 05 Dec 2018, 04:10 PM
Minor correction/clarification.  In the 3rd sentence of my post I wrote 

    "whenever the user types the + or - button"

But I meant to write

   "whenever the user CLICKS the + or - button"

That is, this happens when the user clicks the control with the mouse. There is no typing involved.
0
Joe
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 06 Dec 2018, 05:29 PM
It appears I posted this in the wrong forum.  I did not realize that there was a separate forum devoted specifically to the UpDown control.  I will repost this there.  Please ignore this post
0
Stefan
Telerik team
answered on 07 Dec 2018, 04:23 PM
Hello Joe,

What might be a possible solution apart from editing the template of the control would be to handle its PreviewGotKeyboardFocus event and set the Handled property of the event arguments to true. If this does not suit your needs, you can stick to the approach of altering the default template. You can copy it from the Themes.Implicit folder in your local installation copy. Within it are the default theme files for each theme. You can copy the template from the Windows8Touch folder so that it has the look and feel of the other components in the application. Can you please give one of these approaches a try?

I hope this helps.

Regards,
Stefan
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Joe
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 09 Dec 2018, 04:05 AM

Hi Stefan,

That approach does fix the problem, however at the cost of me losing all of the styles that would normally be applied by Telerik's RadNumericUpDownStyle (which can be found in the Telerik XAML file for the Windows8Touch style.

So if I truly want my Windows8TouchStyle, I am still forced to copy all of those styles from the Telerik-supplied XAML file regardless of which approach I use.

In effect, this is no less overkill then just copying the telerik styles and passing on the "Focusable" property in the TemplateBinding myself.

That's OK.  I can do this. However in the longer term, I hope you will agree with me that this is a bug that needs to be fixed by Telerik.  Admittedly, a minor bug, but a bug nevertheless.

That is to say, the template of the RadNumericUpDown control *must* pass on the entire control's  "Focusable" property to its internal edit control.   It makes no sense that a user could set Focusable=false on the entire control only to have the internal edit control ignore it and still gain focus.

Thanks,

-Joe

0
Accepted
Stefan
Telerik team
answered on 12 Dec 2018, 02:11 PM
Hello Joe,

Thank you for the update.

I would like to clarify, that this behavior is due to the by-design implementation of the control in regards to its focus management. Shortly said, the input box receives focus irrelevant to where exactly the click within the control is. Simply respecting the Focusable property value would not be applicable in this case, as the focus is being set internally in the control logic. I am afraid that we cannot commit to modifying this behavior as this would result in a breaking change. I noticed that this topic is already discussed with my colleague Martin in the other forum thread you opened regarding it. In order to be consistent with our communication may I kindly ask you to continue any further discussion regarding it in the other forum?

Thank you in advance for understanding.

Regards,
Stefan
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Joe
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Joe
Top achievements
Rank 2
Iron
Iron
Veteran
Stefan
Telerik team
Share this question
or