It's a strange case but I don't even know how to debug this problem. My program takes two input languages (English and Arabic), when I first run the program and press any English letter then press Alt+shift to switch the language it doesn't work! then when I press Ctrl+shift to switch the direction to RightToLeft then try Alt+shift again it works! and still working for all cases after that.
actually it may be my code that causes this problem but I can't debug it! I tried.
Note: In a new RichTextBox without code it takes Alt+shift normally but it doesn't accept Ctrl+shift so I added if statement to make ctrl+shift work but it's not the reason of the problem because I tried to remove it and the problem remains
Note2: I don't know if changing selection start
and selection length
causes problems because I am changing them a lot in myFunction but return them to the previous status at the end of function.
my code to make ctrl+shift work
Private Sub RichTextBox_KeyUp(sender As Object, e As KeyEventArgs) Handles RichTextBox.KeyUp
Try
' if Ctrl and Shift are pressed then change text-align ( shift+ctrl OrElse ctrl+shift)
If (e.Modifiers = Keys.Shift OrElse e.Modifiers = Keys.ShiftKey) AndAlso
(e.KeyCode = Keys.ControlKey OrElse e.KeyCode = Keys.Control) OrElse _
_
((e.Modifiers = Keys.Control OrElse e.Modifiers = Keys.ControlKey) AndAlso
(e.KeyCode = Keys.Shift OrElse e.KeyCode = Keys.ShiftKey)) Then
If RichTextBox.RightToLeft = Windows.Forms.RightToLeft.Yes Then ' if align is rightToLeft
RichTextBox.RightToLeft = Windows.Forms.RightToLeft.No ' then make it LeftToRight
Else
RichTextBox.RightToLeft = Windows.Forms.RightToLeft.Yes
End If
RichTextBox.SelectionStart = RichTextBox.TextLength
End If
' Calling subroutine myFunction
Call myFunction()
Catch ex As Exception
End Try
End Sub