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

Numeric entry Clear Command cursor

5 Answers 59 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
danparker276
Top achievements
Rank 2
danparker276 asked on 01 Apr 2011, 06:40 PM
I have a RadMaskedNumericInput box, things are working great except when I press the clear button, I want it to put the cursor at 1 position before the decimal.  I'm inputting hours 0-24 with 2 decimal places (decimal minutes out of 100).  My mask is #2.2 and
When I tab to it and press 1, I want 1.00 and it does that.  If I press the clear button and then press 1, I get 10.00, but I'd like 1.00.  Is there anyway to do that? It moves the cursor to the very start digit.  If I tab out and come back to it, it works fine.

Also is there a way to clear the value at the start?  I always defaults to 0.00.  I sort of like it how it starts with a blank.  I couldn't seem to use the watermark with RadMaskedNumericInput.  I also noticed when it starts default 0.00, if I press 12, I get 1.20  .  But if I clear it with the clear button and come bac
<telerik:RadMaskedNumericInput  Mask="#2.2"  
                 Height="25" FontSize="14" 
                 Name="textBoxHours" HorizontalAlignment="Left"   
                    Width="75" TextMode="PlainText"  
                    ValueChanging="textBoxHours_ValueChanging"
                    Placeholder=" " TabNavigation="Local"
                     IsReadOnly="False"/>
k to it and press 12, I get 12.00.  I like the way it works when I clear it and tab back to it.

5 Answers, 1 is accepted

Sort by
0
danparker276
Top achievements
Rank 2
answered on 01 Apr 2011, 08:11 PM
For watermark I can just use the empty value, and I can set the value to null in the program to start it at the empty content.  But another thing, is when I start from null and enter a '.' I would think it would go to the decimal place.  Instead it does a space.
0
danparker276
Top achievements
Rank 2
answered on 01 Apr 2011, 11:05 PM

I also noticed, when I press the clear button, then press 4, I'll get an exception because I'm trying to limit the hours between 24 - 0.  When I press the 4 it tries to do a 40.  Is it ok to put a value changing like the old way:

        private void textBoxHours_ValueChanging(object sender, Telerik.Windows.Controls.MaskedInput.RadMaskedInputValueChangingEventArgs e)
        {     
       if (e.NewValue != null)
            {
                e.Handled = (((double)e.NewValue > 24) || ((double)e.NewValue < 0));
  
}
}
0
danparker276
Top achievements
Rank 2
answered on 01 Apr 2011, 11:44 PM
I've also noticed if I take out the ValueChanging and just add:

 

 

MaskedInputExtensions.SetMaximum(this.textBoxHours, 24d);

 


to the code behind, I'll get the same error if I hit, the Clear(X) have so it starts at the cursor at the start of #2.2.  Then press the 4 (which tries to make it 40, but the limit is 24).  It will throw an exception.
0
Accepted
Alex Fidanov
Telerik team
answered on 04 Apr 2011, 09:34 AM
Hello danparker276,

Regarding your initial issue, we have a property AllowSkipPlaceholders which will give you the desired behavior.
If you want the control to have a default value when it gets focus, you can use the GotFocus event and set its value to null :

private void textBoxHours_GotFocus(object sender, RoutedEventArgs e)
{
    (sender as RadMaskedNumericInput).Value = null;
}
Setting the AllowSkipPlaceholders to false should allow you to use the ValueChanging event as well as the SetMaximum method correctly. I noticed an issue (when using the extensions with a culture other than en-US) which will be resolved and included in the internal build.

Please let us know when you have the chance to test this and if you still have issues with this behavior.

Best wishes,
Alex Fidanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
danparker276
Top achievements
Rank 2
answered on 04 Apr 2011, 05:16 PM
Thanks, AllowSkipPlaceholders fixed everything
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
danparker276
Top achievements
Rank 2
Answers by
danparker276
Top achievements
Rank 2
Alex Fidanov
Telerik team
Share this question
or