Accept dot (.) from numeric pad as well as comma (,)

Editors for WPF Forum

Posted 6 years ago by Antoine Picard
Version: 18.1.0673
Avatar

Hi,

as a french user, I would like to be able to choose if I want, or not, to accept dots from the numeric pad.

3.14 and 3,14 is the same for us so is there anything to do about it ?

Thanks,

Comments (8)

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

Hi Antoine,

If your Windows region settings for number format are set to use comma as a decimal symbol, are decimal numbers showing up with the comma properly for you?  They seem to be working right here.

Or are you specifically referring to the number pad's key next to the zero key inserting a comma instead of dot in this scenario?  I didn't see Notepad inserting a comma when I had the comma decimal symbol set and I pressed that key.  Do any other apps do that?


Actipro Software Support

Posted 6 years ago by Antoine Picard
Avatar

Hi ! 

Yes it's the number pad's key next to the zero key that is inserting a dot and I just want any ActiPro editor to accept it.
Excel for instance convert it to a coma so it accepts it. And you're right notepad keep it as a dot.

So should I write my own code to workaround that ?

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

Hi Antoine,

I also looked at Word and they have it come through as a dot, like Notepad.  

Yes you would probably have to handle that yourself somehow.  Since we have a regular WPF TextBox in the edit box that takes the input, the typing of the character is a bit out of our hands.  We just see that a "." character gets composed by WPF's text composition, but aren't told that it comes from that particular decimal key.  You might have to block like a KeyDown event for that key to block the text from getting composed how it is currently.


Actipro Software Support

Posted 6 years ago by Antoine Picard
Avatar

Hi !

Okay and in another way, could it be possible to accept dots as decimal separator ? Your textboxes higlight in red and don't accept a value with a dot (3.14 for instance) Is there a way to remove it ? I want to accept either dots and comas.

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

Hello,

Can you tell me exactly how to reproduce the red highlights that you mentioned in one of our samples?  I'm not seeing that in our v2018.1 samples for DoubleEditBox.


Actipro Software Support

Posted 5 years ago by Antoine Picard
Avatar

Hi,

it's quite simple, just type some decimal number using the number pad's key next to the zero key as the decimal separator and it will trigger the red error thing.

I reproduced it with your 2018.1 version.

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

Hi Antoine,

I've tried that but never see the red box you mention.  I'm trying to get more information on which sample of ours you are using.  I have French number format on my system and I tried the Double Edit Box QuickStart.  Then I typed a decumal number in with the keypad.  But I never saw red, and as I tabbed off the control, it restored another value.  Pressing Enter after typing a decimal value never committed the value due to the decimal point.

One thought is that the DoubleEditBox has its InputScopeNameValue property set to Number.  That value gets converted and set to the TextBox.InputScope property on the TextBox in the edit box's template.  Perhaps something within Microsoft's TextBox logic is activating this red box you see, and changing that property would help.  I'm still not sure why I don't see a red box though.


Actipro Software Support

Answer - Posted 5 years ago by Antoine Picard
Avatar

Hi,

We finally choose to create a custom editor and to handle this key.

if (e.Key == Key.Decimal)
{
  TextBox txb = sender as TextBox;
  int caretPos = txb.CaretIndex;
  txb.Text = txb.Text.Insert(txb.CaretIndex,
              CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator);
  txb.CaretIndex = caretPos + 1;
  e.Handled = true;
}
else
{
  OnKeyDown(e);
}
The latest build of this product (v24.1.2) was released 5 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.