PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] InApp keyboard-VBForums
Results 1 to 7 of 7

Thread: [RESOLVED] InApp keyboard

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2016
    Posts
    11

    Resolved [RESOLVED] InApp keyboard

    Hello,

    I want to make InApp keyboard.(on screen keyboard, but i want to use it just in my program). So, i want to write like in 10 different textboxes. I dont know, how to define in which textbox it should write. So if i click on textbox1 i want that my keyboard will write in textbox1, etc for textbox2,3,4....

    Please help me

  2. #2
    Hyperactive Member Vexslasher's Avatar
    Join Date
    Feb 2010
    Posts
    429

    Re: InApp keyboard

    Here is one that I found that was broken I fixed it so that the lowercase and upper case letters work but the numbers are still broken but dunno if they are needed or not. It auto-generates the buttons you may need to change there location it's not hard it's just 4 numbers with Lft and Top that would need changed or 6 if you use the numbers too.

    vb.net Code:
    1. Public Class Form1
    2.     Private Sub BtnCap_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    3.         TextBox1.Text = TextBox1.Text + CType(sender, Button).Text
    4.     End Sub
    5.     Private Sub BtnNor_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    6.         TextBox1.Text = TextBox1.Text + CType(sender, Button).Text
    7.     End Sub
    8.     Private Sub Form1_Load(ByVal sender As Object, _
    9.        ByVal e As System.EventArgs) Handles Me.Load
    10.         Dim BtnCap As Button
    11.         Dim BtnNor As Button
    12.         Dim Lft As Integer = 10
    13.         Dim Top As Integer = 60
    14.         For i As Integer = Asc("A") To Asc("Z")
    15.             BtnCap = New Button
    16.             With BtnCap
    17.                 .Name = "BtnC_" & Chr(i)
    18.                 .Text = "" & Chr(i)
    19.                 .Size = New Size(25, 25)
    20.                 .Location = New Point(Lft, Top)
    21.                 .Tag = Chr(i)
    22.                 Lft = Lft + 20
    23.                 If Chr(i) = "M" Then
    24.                     Top = Top + 30
    25.                     Lft = 10
    26.                 End If
    27.                 .Visible = True
    28.             End With
    29.             Me.Controls.Add(BtnCap)
    30.             AddHandler BtnCap.Click, AddressOf BtnCap_click
    31.         Next
    32.         Dim NLft As Integer = 10
    33.         Dim NTop As Integer = Top + 30
    34.         For j As Integer = Asc("a") To Asc("z")
    35.             BtnNor = New Button
    36.             With BtnNor
    37.                 .Name = "BtnN_" & Chr(j)
    38.                 .Text = "" & Chr(j)
    39.                 .Size = New Size(25, 25)
    40.                 .Location = New Point(NLft, NTop)
    41.                 .Tag = Chr(j)
    42.                 NLft = NLft + 20
    43.                 If Chr(j) = "m" Then
    44.                     NTop = NTop + 30
    45.                     NLft = 10
    46.                 End If
    47.                 .Visible = True
    48.             End With
    49.             Me.Controls.Add(BtnNor)
    50.             AddHandler BtnNor.Click, AddressOf BtnNor_click
    51.         Next
    52.         Call numbers()
    53.     End Sub
    54.     Sub numbers()
    55.         Dim BtnNum As Button
    56.         Dim Lft As Integer = 10
    57.         Dim Top As Integer = 60
    58.         For i As Integer = 0 To 9
    59.             BtnNum = New Button
    60.             With BtnNum
    61.                 .Name = "BtnC_" & i
    62.                 .Text = "" & i
    63.                 .Size = New Size(25, 25)
    64.                 .Location = New Point(Lft, Top)
    65.                 .Tag = i
    66.                 Lft = Lft + 20
    67.                 .Visible = True
    68.             End With
    69.             Me.Controls.Add(BtnNum)
    70.             AddHandler BtnNum.Click, _
    71.                AddressOf BtnCap_click
    72.         Next
    73.     End Sub
    74. End Class

  3. #3
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,191

    Re: InApp keyboard

    Quote Originally Posted by kitajc View Post
    I want to make InApp keyboard.(on screen keyboard, but i want to use it just in my program). So, i want to write like in 10 different textboxes. I dont know, how to define in which textbox it should write. So if i click on textbox1 i want that my keyboard will write in textbox1, etc for textbox2,3,4....
    Any particular reason you don't want to use the on-screen keyboard built into Windows?

    Nevertheless, the way it was done here is writing to whatever the ActiveTextBox object was at the time, which you would set when you click on a TextBox.

    Code:
        Private Sub btn8_Click(sender As System.Object, e As System.EventArgs) Handles btn8.Click
            If activeTextbox.SelectedText.Length > 0 Then
                activeTextbox.SelectedText = ("8")
            Else
                activeTextbox.AppendText("8")
            End If
            activeTextbox.Focus()
        End Sub

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2016
    Posts
    11

    Re: InApp keyboard

    Quote Originally Posted by topshot View Post
    Any particular reason you don't want to use the on-screen keyboard built into Windows?

    Nevertheless, the way it was done here is writing to whatever the ActiveTextBox object was at the time, which you would set when you click on a TextBox.

    Code:
        Private Sub btn8_Click(sender As System.Object, e As System.EventArgs) Handles btn8.Click
            If activeTextbox.SelectedText.Length > 0 Then
                activeTextbox.SelectedText = ("8")
            Else
                activeTextbox.AppendText("8")
            End If
            activeTextbox.Focus()
        End Sub

    Im making app for make foodorder list, its not practicbwinfows keyboard. I made sokution, so every textbox get own keyboard in nes window, but would be better one for all

  5. #5
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,191

    Re: InApp keyboard

    Fair enough. My solution would require you to have code similar to what I showed for each keyboard button. There may be a more elegant solution.

  6. #6
    Hyperactive Member Vexslasher's Avatar
    Join Date
    Feb 2010
    Posts
    429

    Re: InApp keyboard

    I was working with that code from before and I removed the lower cased section and instead just added a "caps lock" button this way it's more like a normal keyboard. I also made it so that you will be able to work with any of your active textboxes using these buttons. I also fixed the buttons for the numbers so it now has the 24 letters that can be set to caps or not and numbers 0 - 9.

    vb.net Code:
    1. Public Class Form1
    2.     Private Sub LetterOrNumber_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    3.         focussedTextBox.Text = focussedTextBox.Text + CType(sender, Button).Text
    4.     End Sub
    5.     Public focussedTextBox As TextBox
    6.     Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    7.         'Working With Only The Active TextBox
    8.         For Each control As Control In Me.Controls
    9.             If control.GetType.Equals(GetType(TextBox)) Then
    10.                 Dim textBox As TextBox = CType(control, Windows.Forms.TextBox)
    11.                 AddHandler textBox.Enter, Sub() focussedTextBox = textBox
    12.             End If
    13.         Next
    14.         'Upper Cased Letters
    15.         Dim BtnCap As Button
    16.         Dim Lft As Integer = 10
    17.         Dim Top As Integer = 60
    18.         For i As Integer = Asc("A") To Asc("Z")
    19.             BtnCap = New Button
    20.             With BtnCap
    21.                 .Name = "BtnC_" & Chr(i)
    22.                 .Text = "" & Chr(i)
    23.                 .Size = New Size(25, 25)
    24.                 .Location = New Point(Lft, Top)
    25.                 .Tag = Chr(i)
    26.                 Lft = Lft + 20
    27.                 If Chr(i) = "M" Then
    28.                     Top = Top + 30
    29.                     Lft = 10
    30.                 End If
    31.                 .Visible = True
    32.             End With
    33.             Me.Controls.Add(BtnCap)
    34.             AddHandler BtnCap.Click, AddressOf LetterOrNumber_click
    35.         Next
    36.         'Numbers
    37.         Dim BtnNum As Button
    38.         Dim NUMLft As Integer = 10
    39.         Dim NUMTop As Integer = Top + 30
    40.         For i As Integer = 0 To 9
    41.             BtnNum = New Button
    42.             With BtnNum
    43.                 .Name = "BtnNum_" & i
    44.                 .Text = "" & i
    45.                 .Size = New Size(25, 25)
    46.                 .Location = New Point(NUMLft, NUMTop)
    47.                 .Tag = i
    48.                 NUMLft = NUMLft + 20
    49.                 .Visible = True
    50.             End With
    51.             Me.Controls.Add(BtnNum)
    52.             AddHandler BtnNum.Click, AddressOf LetterOrNumber_click
    53.         Next
    54.         'caps lock
    55.         Dim BtnCapsLock As New Button With {.Text = "caps lock", .Name = "BtnCapsLock", .Size = New Size(65, 25), .Location = New Point(NUMLft, NUMTop), .Visible = True}
    56.         Me.Controls.Add(BtnCapsLock)
    57.         AddHandler BtnCapsLock.Click, AddressOf BtnCapsLock_click
    58.     End Sub
    59.  
    60.     Private Sub BtnCapsLock_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    61.         For Each control As Control In Me.Controls
    62.             If control.GetType.Equals(GetType(Button)) AndAlso control.Name.Contains("BtnC_") Then
    63.                 Dim letter As String = control.Text
    64.                 control.Name = "BtnN_" & letter.ToLower
    65.                 control.Text = letter.ToLower
    66.                 control.Tag = letter.ToLower
    67.             ElseIf control.Name.Contains("BtnN_") Then
    68.                 Dim letter As String = control.Text
    69.                 control.Name = "BtnC_" & letter.ToUpper
    70.                 control.Text = letter.ToUpper
    71.                 control.Tag = letter.ToUpper
    72.             End If
    73.         Next
    74.     End Sub
    75. End Class

  7. #7

    Thread Starter
    New Member
    Join Date
    Oct 2016
    Posts
    11

    Re: InApp keyboard

    Thank you so much. Worked fine, i made some visual improvements and position, so its perfect for me. Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width