TouchSpy Layout self clicked triggers touch events twice

60 views
Skip to first unread message

Right2TheV0id

unread,
Sep 11, 2022, 3:52:48 PM9/11/22
to DroidScript
Hi,

I discovered that a layout with the "TouchSpy" option triggers touch events twice when clicked (directly).
I presume this is because it "spies itself".

Here's a snippet to test it.
Regards.

function OnStart()
{
    lay = app.CreateLayout( "Linear", "FillXY,TouchSpy" );
    lay.SetOnTouchDown( lay_OnTouchDown );
    app.AddLayout( lay );
}

function lay_OnTouchDown( ev )
{
    var id = ev.source.id;
    var act = ev.action;
    app.Alert( "lay1_OnTouchDown( " + id + ", " + act + " )" );
}


Message has been deleted

Alan Hendry

unread,
Oct 6, 2022, 8:10:43 AM10/6/22
to DroidScript
HI,
Controls within the layout seem to be OK.
I had a problem where the callback was being invoked even when the user didn't touch (and no simulatetouch)
I found that the "phantom" touches had event.X as nonnumeric (), so I coded  !isNaN(event.X)
All the event attributes on your double-touch seem to be OK.
If you change to touchup you still get 2 invocations, and ontouch gives 2 down, 2 up (moves are also doubled) 
Regards, ah

function OnStart(){
    lay = app.CreateLayout( "Linear", "FillXY,TouchSpy" );
    lay.SetOnTouchDown( lay_OnTouchDown );
    btn = app.AddText(lay,"Touch me")

    app.AddLayout( lay );
}
function lay_OnTouchDown( ev ){
    app.Alert( JSON.stringify(ev) );
}
Reply all
Reply to author
Forward
0 new messages