The current NumberBox ControlTemplate does not set the "InputBox" TextBox's InputScope. This means the system will handle it using defaults. It's better to add InputScope="Number" in XAML to ensure the system will handle numerical entry better within the NumberBox. This is especially helpful for virtual keyboards on the desktop and mobile.
In the code here
<TextBox x:Name="InputBox"
Grid.Column="0"
Header="{TemplateBinding Header}"
HeaderTemplate="{TemplateBinding HeaderTemplate}"
PlaceholderText="{TemplateBinding PlaceholderText}"
contract7Present:SelectionFlyout="{TemplateBinding SelectionFlyout}"
SelectionHighlightColor="{TemplateBinding SelectionHighlightColor}"
TextReadingOrder="{TemplateBinding TextReadingOrder}"
PreventKeyboardDisplayOnProgrammaticFocus="{TemplateBinding PreventKeyboardDisplayOnProgrammaticFocus}"
contract7Present:Description="{TemplateBinding Description}"/>
Simply add a new property to the TextBox
InputScope="Number"
This is documented in UWP for the TextBox here and generically here and don't forget the InputScopeNameValue Enum
Better handing of the NumberBox by the system especially with virtual keyboards.
@SavoySchuler @teaP This is an easy one that is a nice-to-have for the NumberBox. If you agree with the concept, I would like to submit the PR myself.
The one issue about setting it to number, is when the common scenario is to do calculations which require operators and brackets - so this InputScope should be overridable.
@mdtauk I don't think this is an issue. I checked and the standard number keyboard has mathematical operators and parenthesis as well. This is true for the touch keyboard on mobile devices at least -- I can't seem to get the keyboard to change on Windows 10 desktop (which means it would show the full keyboard anyway).
<TextBox InputScope="Number"/>
Great suggestion! @robloo I'll assign the issue to you and you can submit your fix? :)
Sure! Will be a few days before I get around to it, but will be happy to submit the PR.
I believe this is not a proposal, but a bug as NumberBox's spec notes here that "Number" _should_ be the InputScope of NumberBox: https://github.com/microsoft/microsoft-ui-xaml-specs/blob/master/active/NumberBox/NumberBox.md#input-scope
@teaP if there was a reason for this change that I forgot to note in the spec, please let me know. I'll turn this over to you unless I am otherwise needed, but it sounds like @robloo may also already have the code fix we need! 馃槃
Thanks for filing this @robloo and for putting the work in to fix it! You rock!
I should get to this next week. @teaP please let me know if there was a reason it wasn't already done.
@robloo Would you like to add the inputscope or would you mind me creating a PR for this quickly?
@chingucoding Thanks for the reminder. I would rather keep this assigned to me and I'll finish it soon. It's an easy one but it will force me to setup the dev environment and read through the contribution docs. This will make future contributions easier.
Okay, sure @robloo . If you need help with setting up the environment or if you have troubles compiling, feel free to ask :)
Most helpful comment
@chingucoding Thanks for the reminder. I would rather keep this assigned to me and I'll finish it soon. It's an easy one but it will force me to setup the dev environment and read through the contribution docs. This will make future contributions easier.