Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub IPAtext_KeyPress(sender As Object, e As KeyEventArgs) Handles IPAtext.KeyDown
- Dim AChars() As Char = {"æ", "ɑ"}
- Dim Counter As Integer = 0
- Select Case e.Modifiers
- Case Keys.Control
- Select Case e.KeyCode
- Case Keys.A
- While e.Modifiers = Keys.Control And e.KeyCode = Keys.A
- IPAtext.AppendText(AChars(Counter))
- '-- Pause for keypress. If keypress =/= A then complete loop, if keypress is A again then increase counter. --
- Counter = (Counter + 1) Mod AChars.Count 'Increments the counter so that it cycles back to 0 when it goes past the count of AChars.
- '-- Only execute the line below if keypress is A. --
- IPAtext.Text = IPAtext.Text.Remove(IPAtext.TextLength - 1) 'Remove the last character from the textbox.
- End While
- End Select
- End Select
- End Sub
- Private Sub RichTextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyDown
- e.SuppressKeyPress = True
- e.Handled = True
- Select Case e.KeyCode
- Case Keys.A And e.Modifiers = Keys.Control
- RichTextBox1.SelectedText = GetCharacterToPrint(RichTextBox1.SelectedText, New Char() {"æ", "ɑ"})
- RichTextBox1.Select(RichTextBox1.SelectionStart - 1, 1)
- Case Else
- e.Handled = False
- e.SuppressKeyPress = False
- End Select
- End Sub
- Private Function GetCharacterToPrint(ByVal SelectedText As String, ByVal Characters As Char()) As Char
- If SelectedText.Length <> 1 Then
- Return Characters(0)
- End If
- Dim c As Char = SelectedText(0)
- Dim index As Integer = String.Join("", Characters).IndexOf(c)
- If index = Characters.Length - 1 Then
- Return Characters(0)
- Else
- Return Characters(index + 1)
- End If
- End Function
- Private Sub RichTextBox1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyUp
- If e.KeyValue = Keys.ControlKey Then
- RichTextBox1.SelectionStart += 1
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement