Android Question Unwanted TOUCH up events

JeffT

Member
Licensed User
I developed an android app to a point, but have reached a brick wall that makes further work pointless unless I can resolve it.

Essentially, at heart, we can draw on screen using finger or mouse etc.
I detect when the 'pointer' goes down, when it moves, and when it is lifted.
At the point it is lifted, I do some storage.

My problem is that when I use an attached mouse to do this, all works nice and smoothly.
But if I rely on a finger on screen, I get unwanted and incorrect pointer UP events even when the finger has never lost contact with the screen.
As a result, storage stuff gets called when it shouldnt, the feedback is totally lost, and its a bad experience.

Is this 'pointer up' thing a known issue when using a finger, is it something I can code for?
 

josejad

Expert
Licensed User
Longtime User
You can take a look to some projects doing something similar:


Probably it's a good idea to show your code in order someone can take a look.
It would be interesting too, to see how using the mouse with an android device.
 
Upvote 0

JeffT

Member
Licensed User
It would be interesting too, to see how using the mouse with an android device.

Literally, just plug one in or connect using bluetooth.
You get the same events as a finger, but more reliably and more accurately.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Upvote 0

udg

Expert
Licensed User
Longtime User
Could it be somewhat related to the quality of the touch surface?
I mean, does it still happen if you drag your finger (TOUCH_MOVE actions) pressing the surface with some extra strength? If not, probabily at some point the surface "doesn't register the contact of your finger" so the sw raises the UP event.
 
Upvote 0

JeffT

Member
Licensed User
What I can say is that when the finger goes down,
I get Action = 0
While moving, ACTION = 2 (Why arent these enumerations documented?)
When the TOUCH UP happens, Action is 1

The only other documented action appears to be MOVE_NOTOUCH which shouldnt happen in Android, and that has a value of 100

So when this happens, I am seeing an Action of '3' happening.
That makes no sense, unless we are supposed to interpret it bitwise as a combination of both 'UP' and 'MOVING'

(Ive seen odd codes like 261 and 262 appear also)
 
Upvote 0

JeffT

Member
Licensed User
Code used (Some removed as not important, some variables are global)

B4X:
Sub Pane1_Touch (Action As Int, X As Float, Y As Float)
    'assuming only one pointer


    Dim thex As Int =Floor(X/ zoomsize)
    Dim they As Int =Floor(y/ zoomsize)
    Dim screenx As Int
    Dim screeny As Int
    screenx = thex * zoomsize
    screeny = they * zoomsize


    Dim lineendactx As Float
    Dim lineendacty As Float
    Dim actx As Int
    Dim acty As Int
    actx = thex + topleftx
    acty = they + toplefty

    Log (Action)
    
    Select Case Action
        Case Pane1.TOUCH_ACTION_DOWN
            'record when the pointer went down, for backstitch and lines
            linestartactx =screenx 'todo ... on the halves
            linestartacty =screeny 'todo.. on the halves
            linestartx =thex 'todo ... on the halves
            linestarty =they 'todo.. on the halves
            
          
            redraw (True)
        
            
        Case Pane1.TOUCH_ACTION_MOVE
            'Log (x & " " & Y)

        
                If  ( lastx <> actx Or lasty <> acty) Then
                    'Log ("do it")
                    Select Case drawmode
                        Case draw_00Normal
                            rct.Initialize (thex*zoomsize,they * zoomsize, thex*zoomsize + zoomsize,they * zoomsize + zoomsize)
                            maingrid2.DrawRect (rct, thecolor,True,1)


                          'other cases removed
                            
                    End Select
                    maingrid2.Invalidate
          
            End If
            lastx =actx
            lasty = acty
            
        Case      Pane1.TOUCH_ACTION_UP
            
 

            redraw (True)


          'store a copy for undo

            pushacopy 'make a backup
            
            
        Case     Else
          ' this is debugging so that I can see what is being delivered
            
            Private thecode As Int
            thecode = Action
            
            thecode = Pane1.TOUCH_ACTION_MOVE_NOTOUCH
            thecode = Pane1.TOUCH_ACTION_UP
            thecode = Pane1.TOUCH_ACTION_DOWN
            thecode = 1
            
                    
    End Select
    maingrid2.Invalidate   'this is the control that does the display of data and should be getting the events
End Sub
 
Upvote 0
Top