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

Programmatic Focus behaves different than tab or selecting

1 Answer 74 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 06 Mar 2014, 07:14 PM
Then I click on a MaskedTextInput, it's all selected and in insert mode, so if I have '8888' in the value and press 1, everything is replaced by 1.

When I set the focus on the code behind, I press '1' and get '1888' then when I press 1 again I get '11888' .  It's very strange behavior.

I have some sample code below.  When you press the button I programmatically set the focus on the RadMaskedTextInput.  Compare this to when you selected it with a mouse, or tab to it:

<Window x:Class="FocusOnTextBox6.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.Resources>
            <Style x:Key="UpperCodes6Mask" TargetType="telerik:RadMaskedTextInput">
                <Setter Property="FontFamily" Value="Segoe UI" />
                <Setter Property="Margin" Value="0 0 0 0" />
                <Setter Property="Width" Value="60" />
                <Setter Property="Height" Value="20" />
                <Setter Property="Padding" Value="0" />
                <Setter Property="Placeholder" Value=" " />
                <Setter Property="IsClearButtonVisible" Value="False" />
                <Setter Property="TextMode" Value="PlainText" />
                <Setter Property="SectionsNavigationMode" Value="None" />
                <Setter Property="IsLastPositionEditable" Value="False" />
                <Setter Property="InputBehavior" Value="Insert" />
                <Setter Property="SelectionOnFocus" Value="SelectAll" />
                <Setter Property="Mask" Value=">a6" />
            </Style>
        </Grid.Resources>
        <StackPanel Orientation="Horizontal">
            <telerik:RadMaskedTextInput Margin="3 0 0 0" Height="20" Padding="0"  Style="{StaticResource UpperCodes6Mask}"
                    Name="tbClid" />
 
            <TextBox Name="tbTest" Margin="10 0 0 0" Height="25"  Width="50"/>
            <Button Name="btnTest" Margin="20 0 0 0" Content="Test Focus" Height="25" Width="100" Click="btnTest_Click" />
 
            <Button Name="btnTestRegular" Margin="20 0 0 0" Content="Test Focus TextBox" Height="25" Width="100" Click="btnTestRegular_Click" />
 
        </StackPanel>
    </Grid>
</Window>


namespace FocusOnTextBox6
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
 
        private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            tbClid.Value = "8888";
            tbClid.Focus();
 
        }
 
        private void btnTestRegular_Click(object sender, RoutedEventArgs e)
        {
 
            tbTest.Text = "9999";
  
            tbTest.Focus();
            tbTest.SelectAll();
        }
    }
}

1 Answer, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 11 Mar 2014, 01:00 PM
Hello,

Thank you for pointing this out. I have logged this as a bug report and our developers will investigate it in details. As a gratitude to your finding your Telerik points are now updated.

You can keep track on the progress of this bug report and to vote for it using the link below:
http://feedback.telerik.com/Project/143/Feedback/Details/122509-maskedinput-focus-behaves-different-when-it-is-set-in-code-behind

Regards,
Peshito
Telerik

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
danparker276
Top achievements
Rank 2
Answers by
Peshito
Telerik team
Share this question
or