Numeric entry Clear Command cursor

6 posts, 1 answers
  1. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 01 Apr 2011 Link to this post

    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.
  2. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 01 Apr 2011 Link to this post

    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.
  3. DevCraft banner
  4. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 01 Apr 2011 Link to this post

    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));
      
    }
    }
  5. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 01 Apr 2011 Link to this post

    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.
  6. Answer
    Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 04 Apr 2011 Link to this post

    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
  7. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 04 Apr 2011 Link to this post

    Thanks, AllowSkipPlaceholders fixed everything
Back to Top
DevCraft banner