AC.AvalonControlsLibrary.Controls.TimePicker.TryFocusNeighbourControl C# (CSharp) Method

TryFocusNeighbourControl() private static method

private static TryFocusNeighbourControl ( TextBox currentControl, TextBox leftControl, TextBox rightControl, Key keyPressed ) : void
currentControl System.Windows.Controls.TextBox
leftControl System.Windows.Controls.TextBox
rightControl System.Windows.Controls.TextBox
keyPressed Key
return void
        private static void TryFocusNeighbourControl(TextBox currentControl, TextBox leftControl, 
            TextBox rightControl, Key keyPressed)
        {
            if (keyPressed == Key.Left &&
                leftControl != null &&
                currentControl.CaretIndex == 0 )
            {
                leftControl.Focus();
            }

            else if (keyPressed == Key.Right &&
                 rightControl != null &&
                //if the caret index is the same as the length of the text and the user clicks right key it means that he wants to go to the next textbox
                 currentControl.CaretIndex == currentControl.Text.Length ) 
            {
                rightControl.Focus();
            }
        }