Unexpected behavior of Paste

4 posts, 1 answers
  1. Vadimir
    Vadimir avatar
    24 posts
    Member since:
    Aug 2013

    Posted 16 Jul 2014 Link to this post

    Hi,
    I'm using Telerik version 2014.2.617.40. The MaskedtextInput control in Masked Input Text Input Demo has an unexpected behavior.
    Here is the configuration I have.
      Mask: (empty)
      Text Mode: MaskedText.
      Input Behavior: Replace
      Selection On Focus: SelectAll
      Update Value Event: PropertyChanged.

    Replication Steps:
    1. Type ABC in text input.
    2. Select A. Copy A using Ctrl + C.
    3. Select B. Paste using Ctrl + V.
    What I expect: ABC becomes AAC.
    Actual result: ABA.

    Is it a bug? or should I modify the control properties?
    Thanks.

    Regards,
    Gong
  2. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 17 Jul 2014 Link to this post

    Hello Gong,

    Thank you for your question.

    We will need some time to investigate this behavior. As soon as we have more information on that matter we will contact you again. Please excuse us for any inconvenience caused.

    In the mean time as a workaround you can inherit the RadMaskedTextInput and override its HandlePaste() method.

    protected override void HandlePaste()      
    {
        string txt = Clipboard.GetText();
        // insert the text in the Value variable   
    }

    In this case you will need to remove the binding for the default PasteCommand, otherwise the HandlePaste() method will be called twice. You can do it with the following code snippet:

    void maskedInput_Loaded(object sender, RoutedEventArgs e)
    {
        TextBox tBox = (sender as RadMaskedInputBase).ChildrenOfType<TextBox>().FirstOrDefault();
        if (tBox != null)
        {
            tBox.CommandBindings.Clear();
        }           
    }

    For your convenience I prepared a sample project demonstrating this approach. Please give it a try and let  me know if it helps. Also, note that this is a custom implementation that is not well tested and doesn't check for all border cases, this is why I recommend you to test it before use it in your code.

    Regards,
    Martin
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Vadimir
    Vadimir avatar
    24 posts
    Member since:
    Aug 2013

    Posted 17 Jul 2014 in reply to Martin Link to this post

    Hi Martin,
    Thanks for your reply. I'm looking forward to a permanent solution.

    Regards,
    Gong
  5. Answer
    Martin
    Admin
    Martin avatar
    1101 posts

    Posted 18 Jul 2014 Link to this post

    Hi Gong,

    We can confirm this is a bug of the paste functionality in the RadMaskedTextInput control. We logged it in our feedback portal where you can track its status and vote for its fix. We also updated your Telerik points as a small gesture of compensation for any inconvenience caused.

    Regards,
    Martin
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top