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

RadMaskedEditBox cursor location

1 Answer 196 Views
MaskedEditBox
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 22 Apr 2013, 10:26 AM
Hi,

I have a Masked Edit Box with mask type Numeric and mask = "n2"

When I edit the value in the text box, I find there are 3 possible data entry scenarios, and one is causing our users problems.

Assume the field already contains a value "23.55" and the user wishes to change this to "23.65" :

1 - Focus the field so that the entire contents are pre selected and highlighted. Typing overwrites the current contents so the user manually enters the new value completely as "23.65" including the decimal point. The final value is correct and this behavior is intuitive.

2 - Click into field to deselect the contents. The entry caret is at the end of the string. Left arrow twice so that the caret move two characters to the left and is AFTER is the decimal point. Type "65" and this replaces the existing "55" value so the complete field contents are now "23.65". This is again expected and intuitive.

3 - Click into the field to deselect contents. Caret is at the end of the string. Backspace twice and the data entry caret now jumps to BEFORE the decimal point. Enter "65" as with case 2, but now the value is "2365.00" which is incorrect. I would expect the caret to remain AFTER the decimal point as with case two, as jumping over the decimal places is a three character move to the left.

Our users are performing very rapid and high volume data entry and the different caret position and different behavior can be very difficult to spot, so they are finding highly significant data entry errors with values being out by thousands. I would expect the left arrow and backspace to leave the caret AFTER the decimal point to help prevent this and more accurately reflect the number of keypresses and characters navigated.

Is there any way to prevent the caret jumping to BEFORE the decimal after backspace?

Many thanks

Mark.









1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 24 Apr 2013, 01:10 PM
Hi Mark,

Thank you for writing.

I was able to reproduce the issue. I have logged this in our Public Issue Tracking System - PITS. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - PITS Issue
For the time being you can use the following workaround:
this.RadMaskedEditBox1KeyPress += new KeyPressEventHandler(RadMaskedEditBox_KeyPress);
 
void RadMaskedEditBox_KeyPress(object sender, KeyPressEventArgs e)
 {
     RadMaskedEditBox textBox = ((RadMaskedEditBox)sender);
     int selectionStart = textBox.SelectionStart;
     bool beforePoint = selectionStart - 2 >= 0 && textBox.Text[selectionStart - 2] == '.';
 
     if (e.KeyChar == 8 && beforePoint)
     {               
         NumericMaskTextBoxProvider numericProvider = (NumericMaskTextBoxProvider)textBox.MaskedEditBoxElement.Provider;
         numericProvider.KeyPress(sender, e);
         e.Handled = true;
         textBox.SelectionStart++;
     }
 }

I have also updated your Telerik points for bringing this issue to our attention.

Should you have any other questions or suggestions, do not hesitate to contact us.

Regards,
Peter
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
Tags
MaskedEditBox
Asked by
Mark
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or