Event.xStart is always returning 0 when doing swipe on a Page using iPad Mini

Hi,

We have an error using Gestures only on iPad Mini and iPad Air, we have an app that works perfectly on iPad 2, iPad Retina, iPhone 5S , iPhone 5C and iTouch late generation, but when the app is used on an iPad Mini, the gestures doesn’t work.

Within the code, we use event.x and event.xStart to see if the user is making a swipe, on iPad Mini, the event.xStart always return 0.

Any ideas??

Thanks in advance.

Hi @jose.silva,

What object are you detecting touch upon? We’ll almost definitely need to see some code on how you’re doing this…

Brent

Hi Brent, we’re using the dmc_gesture file that comes with Kwiksher, but everything works fine except on iPads Mini… here is the code for the Handler…


function swipeTouchHandler( event )

–print( “swipeTouchHandler”, event )

        --print (“swipeTouchHandler”, event.x , event.xStart)

local obj = event.target

local dmc = obj.__dmc.gesture

local et, xDelta, yDelta, vector, angle

– create our event to dispatch

local e = {

name = SWIPE_EVENT,

phase = event.phase,

target = obj,

direction = nil,

touch = {}

}

–== Start processing the Corona touch event ==–

if event.phase == ‘began’ then

TouchMgr:setFocus( event.target, event.id )

– fill in event and dispatch

et = e.touch

et.xStart = event.xStart

et.yStart = event.yStart

et.x = event.x

et.y = event.y

if obj.dispatchEvent ~= nil then

obj:dispatchEvent( e )

end

return true

elseif event.phase == ‘moved’ then

if event.isFocused then

xDelta = event.x - event.xStart

yDelta = event.y - event.yStart

vector = vector_given_x_y( xDelta, yDelta )

angle = angle_given_x_y( xDelta, yDelta )

e.swipe = {

angle = angle,

length = vector

}

– fill in rest of event and dispatch

et = e.touch

et.xStart = event.xStart

et.yStart = event.yStart

et.x = event.x

et.y = event.y

if obj.dispatchEvent ~= nil then

obj:dispatchEvent( e )

end

return true

end

elseif ( event.phase == ‘ended’ or event.phase == ‘canceled’ ) then

if event.isFocused then

TouchMgr:unsetFocus( event.target, event.id )

if dmc == nil or obj == nil or obj.dispatchEvent == nil then

return true

end

if dmc.useStrictBounds then

                               – print (“1”)

local bounds = obj.contentBounds

                                --print (“Event x ----->>”, event.x …" - " … bounds.xMin … " - " …bounds.xMax)

xDelta = checkBounds( event.x, { bounds.xMin, bounds.xMax } ) - event.xStart

yDelta = checkBounds( event.y, { bounds.yMin, bounds.yMax } ) - event.yStart

                

else

                               – print (“2” … " *** " … event.x , event.xStart)

xDelta = event.x - event.xStart

yDelta = event.y - event.yStart

end

                        --print (“3”)

                        --print (“xDelta”, xDelta, yDelta)

            

vector = vector_given_x_y( xDelta, yDelta )

angle = angle_given_x_y( xDelta, yDelta )

e.swipe = {

angle = angle,

length = vector

}

                        --print (“vector y swipelenght”, vector, dmc.swipeLength)

            

if vector >= dmc.swipeLength then

e.direction = direction_given_angle( angle, dmc.limitAngle )

end

– fill in rest of event and dispatch

et = e.touch

et.xStart = event.xStart

et.yStart = event.yStart

et.x = event.x

et.y = event.y

if obj.dispatchEvent ~= nil then

obj:dispatchEvent( e )

end

return true

end

end

end

Hi @jose.silva,

Well, we can’t provide much support for 3rd-party code. Please test this using the following simplified code, and confirm if you’re still getting incorrect responses on the iPad Mini.

This code detects the touch point data on the entire display stage. If this works on all devices, then the issue is probably in your code, not the Corona core.

[lua]

local function touchTest( event )

   if event.phase == “began” then

      print( “event.phase”, event.phase )

      print( “event.x”, event.x )

      print( “event.y”, event.y )

      print( “event.xStart”, event.xStart )

      print( “event.yStart”, event.yStart )

   end

end

display.currentStage:addEventListener( “touch”, touchTest )

[/lua]

Brent

Hi Brent,

Thanks for your answer, we found that if we had enabled the System. Multitouch, the iPad Mini doesn’t work well detecting swipes.

Thanks for your kindly help.

Best

I found the following incident.  I am going to test it with the latest daily build.

https://forums.coronalabs.com/topic/57535-coronaviewer-stopped-working/?p=300725

Hi @jose.silva,

What object are you detecting touch upon? We’ll almost definitely need to see some code on how you’re doing this…

Brent

Hi Brent, we’re using the dmc_gesture file that comes with Kwiksher, but everything works fine except on iPads Mini… here is the code for the Handler…


function swipeTouchHandler( event )

–print( “swipeTouchHandler”, event )

        --print (“swipeTouchHandler”, event.x , event.xStart)

local obj = event.target

local dmc = obj.__dmc.gesture

local et, xDelta, yDelta, vector, angle

– create our event to dispatch

local e = {

name = SWIPE_EVENT,

phase = event.phase,

target = obj,

direction = nil,

touch = {}

}

–== Start processing the Corona touch event ==–

if event.phase == ‘began’ then

TouchMgr:setFocus( event.target, event.id )

– fill in event and dispatch

et = e.touch

et.xStart = event.xStart

et.yStart = event.yStart

et.x = event.x

et.y = event.y

if obj.dispatchEvent ~= nil then

obj:dispatchEvent( e )

end

return true

elseif event.phase == ‘moved’ then

if event.isFocused then

xDelta = event.x - event.xStart

yDelta = event.y - event.yStart

vector = vector_given_x_y( xDelta, yDelta )

angle = angle_given_x_y( xDelta, yDelta )

e.swipe = {

angle = angle,

length = vector

}

– fill in rest of event and dispatch

et = e.touch

et.xStart = event.xStart

et.yStart = event.yStart

et.x = event.x

et.y = event.y

if obj.dispatchEvent ~= nil then

obj:dispatchEvent( e )

end

return true

end

elseif ( event.phase == ‘ended’ or event.phase == ‘canceled’ ) then

if event.isFocused then

TouchMgr:unsetFocus( event.target, event.id )

if dmc == nil or obj == nil or obj.dispatchEvent == nil then

return true

end

if dmc.useStrictBounds then

                               – print (“1”)

local bounds = obj.contentBounds

                                --print (“Event x ----->>”, event.x …" - " … bounds.xMin … " - " …bounds.xMax)

xDelta = checkBounds( event.x, { bounds.xMin, bounds.xMax } ) - event.xStart

yDelta = checkBounds( event.y, { bounds.yMin, bounds.yMax } ) - event.yStart

                

else

                               – print (“2” … " *** " … event.x , event.xStart)

xDelta = event.x - event.xStart

yDelta = event.y - event.yStart

end

                        --print (“3”)

                        --print (“xDelta”, xDelta, yDelta)

            

vector = vector_given_x_y( xDelta, yDelta )

angle = angle_given_x_y( xDelta, yDelta )

e.swipe = {

angle = angle,

length = vector

}

                        --print (“vector y swipelenght”, vector, dmc.swipeLength)

            

if vector >= dmc.swipeLength then

e.direction = direction_given_angle( angle, dmc.limitAngle )

end

– fill in rest of event and dispatch

et = e.touch

et.xStart = event.xStart

et.yStart = event.yStart

et.x = event.x

et.y = event.y

if obj.dispatchEvent ~= nil then

obj:dispatchEvent( e )

end

return true

end

end

end

Hi @jose.silva,

Well, we can’t provide much support for 3rd-party code. Please test this using the following simplified code, and confirm if you’re still getting incorrect responses on the iPad Mini.

This code detects the touch point data on the entire display stage. If this works on all devices, then the issue is probably in your code, not the Corona core.

[lua]

local function touchTest( event )

   if event.phase == “began” then

      print( “event.phase”, event.phase )

      print( “event.x”, event.x )

      print( “event.y”, event.y )

      print( “event.xStart”, event.xStart )

      print( “event.yStart”, event.yStart )

   end

end

display.currentStage:addEventListener( “touch”, touchTest )

[/lua]

Brent

Hi Brent,

Thanks for your answer, we found that if we had enabled the System. Multitouch, the iPad Mini doesn’t work well detecting swipes.

Thanks for your kindly help.

Best

I found the following incident.  I am going to test it with the latest daily build.

https://forums.coronalabs.com/topic/57535-coronaviewer-stopped-working/?p=300725