Question

MaskedTextBox deletes entire string on keyboard press at front

Posted 5 months ago by Avatar Brian Pratt

Steps to reproduce:

1) Open the Actipro Software WPF Controls Sample Browsesr application

2) Go to Editors > Masked Text Box

3) Enter this as a mask: 

(\d*|NaN),(NaN|\d*)

 4) Enter "NaN,1234" into the top text box (with the "Text matches mask" checkbox)

5) Place your cursor at the beginning of the text box (next to the first "N" in "NaN")

6) Hit the delete key

7) Expected: "NaN" is deleted leaving the ",1234"

8) Actual: Everything is deleted but the comma, leaving "," in the text box

 

Is there a way to stop this from happening?  I want to be able to edit the first number while leaving the second number.  (the PointEdit does not work in my case because you recently removed the "AllowNaN" feature).

EDIT: 

More Info: if I use a single character placeholder instead of NaN, it seems to work correctly.

Doesnt work

[NaN, 1234]

 does work

[*,1234]

 

Thanks,

Brian

[Modified 5 months ago]


Comments (3)

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

Hi Brian,

I'd probably recommend this pattern instead:  (\d+|NaN),(NaN|\d+)

But note it's still going to happen like above because it's running through the regular expression looking for a match.  In your case, after the delete the text is "aN,1234" which is not valid so the rest of it is cleared.

You can select the "NaN" text and type a number there without having the rest clear since that still adheres to the regex pattern.  It's not as ideal as being able to delete the NaN text one character at a time.  However there's no real good way to support that with this control without breaking other things.

In regards to the other PointEditBox issue, we can continue discussion on that in the related forum thread.


Actipro Software Support
Posted 5 months ago by Brian Pratt

Thanks for your help and suggestions.

We went with using one character (  *  ) instead of NaN (which was not very user friendly anyway).  So I think we are good for now.

Just a thought, the editor automatically adds the text "NaN" to the textbox when you type the letter N, so it is doing some sort of look-ahead or auto-fill already.  Could it detect delete the same way?  (look ahead for one of the regex options).

Thanks,

Brian

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

Hi Brian,

The look-ahead works since it's matching everything in the regex up to that point and then if it sees literal text in the pattern right after the current input match, it auto-fills in the literals.  When deleting in this case, the regex is immediately invalid at the start so we don't know how to back things out in the same way.

Using a single character is probably better, and we'll see what we can do to help with PointEditBox.


Actipro Software Support
Information The latest build of this product (2018.1 build 0671) was released 1 month ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.