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

Unexpected behavior of Paste

3 Answers 117 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Vadimir
Top achievements
Rank 1
Vadimir asked on 16 Jul 2014, 08:11 AM
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

3 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 17 Jul 2014, 08:44 AM
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.
 
0
Vadimir
Top achievements
Rank 1
answered on 17 Jul 2014, 09:23 AM
Hi Martin,
Thanks for your reply. I'm looking forward to a permanent solution.

Regards,
Gong
0
Accepted
Martin Ivanov
Telerik team
answered on 18 Jul 2014, 08:26 AM
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.
 
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Vadimir
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Vadimir
Top achievements
Rank 1
Share this question
or