How to enable '.' input from the numeric keypad in a DoubleEditBox

Editors for WPF Forum

Posted 12 years ago by BLANC Stéphane - Staubli Robotics Suite Product Manager, STAUBLI
Version: 12.1.0561
Avatar

Hello,

I use the DoubleEditBox and I would like to insert a "," when the user press the "." in the numeric keypad.
Is it possible ?

Thank you

Stéphane

Comments (6)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Stéphane,

Unfortunately it is not possible to insert a "," (comma) when the "." (decimal) key is pressed on the numerical pad. The insertion of the text comes from a TextInput event from WPF; we do not handle individual keys so we can't alter the input. If there are any other questions you have, please don't hesitate to ask.


Actipro Software Support

Posted 12 years ago by BLANC Stéphane - Staubli Robotics Suite Product Manager, STAUBLI
Avatar

I'm a bit surprised...
A DoubleEditBox that can't edit Double from the numeric pad :o)

It's not useful and acceptable for the user.

Why not replacing the "." on the numeric pad by the System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator internaly ?

Stéphane

Posted 12 years ago by BLANC Stéphane - Staubli Robotics Suite Product Manager, STAUBLI
Avatar

I found this sample on internet but I failed to do the same thing for your control.
Do you have an idea to make a workaround ?

Thanks for your help

Stéphane

 

protected override void OnKeyDown(System.Windows.Input.KeyEventArgs e)
{
if (e.Key == Key.Decimal)
{
var txb = sender as TextBox;
int caretPos = this.CaretIndex;
txb.Text = txb.Text.Insert(txb.CaretIndex, System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator);
txb.CaretIndex = caretPos + 1;

e.Handled = true;
}
else
{
base.OnKeyDown(e);
}
}

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Stéphane,

We use the standard WPF TextInput to know what text is being typed.  The reason we do that is because it is the result of composed text by any culture.  Using key-specific input is not generally a good idea since some foreign keyboards can assign different meanings to keys, especially when certain modifier keys are pressed.

If you put a regular TextBox on a window and use the numeric pad's "." button to enter a character, what do you see entered, comma or dot?  Whatever is entered there is what should be in ours as well, and is what the system is telling us the correct culture-specific text is for that key on your system.


Actipro Software Support

Posted 12 years ago by BLANC Stéphane - Staubli Robotics Suite Product Manager, STAUBLI
Avatar

In a regular Textbox the "." of the numeric keypad insert a dot but I want to have the same behaviour as in Excel for example.

In Excel, the "." of the numeric keypad insert the System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator depending on the current culture.

Could you help me to find a workaround, I relally want to use the DoubleEditBox control ?

Answer - Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Stéphane,

We've been working on this.  It appears to be an issue in general with keyboard input for FR culture, since we've seen the same thing reported on Microsoft's forums and other competitor web sites.

I believe we came up with a workaround for all our double parts though, and would love for you to be able to help test it in a preview build.  If you would like to help test it, please email our support address, reference this thread, and we'll send you a link to a preview build.


Actipro Software Support

The latest build of this product (v24.1.2) was released 0 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.