Android Question How to Create a Gesture Typing

Lyndon Bermoy

Active Member
Licensed User
Longtime User
How to Create a Gesture Typing?

I want to create a sample application that involves typing of shortcuts using gesture.

For example, I typed "1" or "2" in the panel using the tip of my finger then the app can automatically recognized that I have inputted "1" or "2" and then displays in the textbox.

Is it really possible? Thanks for the reply.

Long live B4A! :)
 

eurojam

Well-Known Member
Licensed User
Longtime User
here is a simple example which counts the taps on the grey panel:
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private Panel1 As Panel

    Private EditText1 As EditText
    Private t As Timer
    Private count As Int
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("1")
    Panel1.Initialize("Panel1")
    EditText1.Initialize("EditText1")
    Panel1.Color=Colors.LightGray
    EditText1.TextSize=20
    Activity.AddView(Panel1,0,0,100%x,50%y)
    Activity.AddView(EditText1,0,75%y,100dip,40dip)
 

    t.Initialize("timer1", 1000) 'max time (milisecs) between taps which will be counted

End Sub

Sub Panel1_Touch (Action As Int, X As Float, Y As Float)
    Log(Action & " x=" & x & " y=" & Y)

    If Action = 1 Then
        If t.Enabled Then
            count = count + 1
            t.Enabled=True
        Else 
          count = 1         
          t.Enabled=True
        End If
    End If
End Sub
Sub timer1_tick
    t.Enabled=False
    EditText1.Text = "Taps " & count
End Sub
 
Upvote 0

Lyndon Bermoy

Active Member
Licensed User
Longtime User
here is a simple example which counts the taps on the grey panel:
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private Panel1 As Panel

    Private EditText1 As EditText
    Private t As Timer
    Private count As Int
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("1")
    Panel1.Initialize("Panel1")
    EditText1.Initialize("EditText1")
    Panel1.Color=Colors.LightGray
    EditText1.TextSize=20
    Activity.AddView(Panel1,0,0,100%x,50%y)
    Activity.AddView(EditText1,0,75%y,100dip,40dip)


    t.Initialize("timer1", 1000) 'max time (milisecs) between taps which will be counted

End Sub

Sub Panel1_Touch (Action As Int, X As Float, Y As Float)
    Log(Action & " x=" & x & " y=" & Y)

    If Action = 1 Then
        If t.Enabled Then
            count = count + 1
            t.Enabled=True
        Else
          count = 1        
          t.Enabled=True
        End If
    End If
End Sub
Sub timer1_tick
    t.Enabled=False
    EditText1.Text = "Taps " & count
End Sub


Sir it's not 'tapping'. It's typing.What I need is to have a sketch to text translator.
 
Upvote 0
Top