Problems with p_touch

fatman

Active Member
Licensed User
Longtime User
Hi Folks,

when i´m starting this code:

Sub p_Touch (Action As Int, X As Float, Y As Float) As Boolean
Activity.Title = action
Return True
End Sub

the result is always 1 or 2 shown in the titlebar. I would have expected at least 1,2 or 3.
There is no difference between ACTION_DOWN or ACTION_UP...?
Did I miss something or has anyone experienced this too? Maybe this depends on the device? I got a Toshiba AT100.

Any comments are welcome!
 

fatman

Active Member
Licensed User
Longtime User
Thanks Erel for your prompt reply!
Even if i try your example you gave to derez my system does not deliver zero for ACTION_DOWN.
Think it depends on the hardware- bad enough i have not a second device here.
I´ll try finding a workaround.

Thanks again
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You don't need to look for a workaround.
On my device I don't see 0 either with your code.
But don't worry the Touch ACTION_DOWN event does exist and is raised.
Try the code below and you will see it.
B4X:
Sub Globals
    Dim p As Panel
    Dim lbl1, lbl2, lbl3 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    p.Initialize("p")
    Activity.AddView(p, 0, 0, 100%x, 100%y)
    
    lbl1.Initialize("")
    p.AddView(lbl1,10dip, 10dip, 150dip, 40dip)
    lbl2.Initialize("")
    p.AddView(lbl2,10dip, 60dip, 150dip, 40dip)
    lbl3.Initialize("")
    p.AddView(lbl3,10dip, 110dip, 150dip, 40dip)
End Sub

Sub p_Touch (Action As Int, X As Float, Y As Float) As Boolean
    Select Action
    Case Activity.ACTION_DOWN
        lbl1.Text = "down"
    Case Activity.ACTION_MOVE
        lbl2.Text = "move"
    Case Activity.ACTION_UP
        lbl3.Text = "up"
    End Select
    Return True
End Sub
Best regards.
 
Upvote 0
Top