[FIXED] Touch doesn't work

Hey there,

I opened my current project with your new graphics 2.0 built and set the graphicsCompatibility mode to 1. everything looks the way it was but I can not click anything, no listener seems to work, nothing seems to happen. don’t get any error message either. why is that?

really excited about it btw.

Mac OSX 10.8.5

Graphics 2.0 build 2001

Corona Simulator

That’s a bit weird. I took one of my apps and enabled V1 compatibility mode, and it works as expected.

It’s a business app using widgets though, if that makes a difference…

@romanfischer

We found one issue with touch events and masking that was fixed as of the last daily build.  Is your project using masking?

If you can attach a small bit of sample code we can try to reproduce the issue.

thanks for your quick reply.

well, how about this:

local test = display.newText('hello',0,0,"Arial",16) test.x = display.contentWidth / 2 test.y = display.contentHeight / 2 function touchlistener(event) if event.phase == "began" then print('test') end end test:addEventListener("touch", touchlistener)

doesn’t work in build 2013.2001 nor in build 2013.2000

works in build 2013.1225

did the method change? am I doing something wrong? Doesn’t matter if it’s a text or an image btw…

I’m on Mac OSX

edit: I tried this code in a new blank app

I tested your sample with build 2001 and everything appears to be working normally with the test message going to the console window correctly. It was tested with compatibility mode on and off.

Mac OSX 10.8.5

Corona Graphics 2.0 build 2001

Corona Simulator

I can also confirm that the test code given above works for me as well.

The “test” message is printed in the console when “hello” is tapped.

thanks for your feedback.

Okay but that’s so weird. why is it so? What version of xcode do you have? I have like 4.6, still stuck with ios sdk 6… that’s the only thing I can think of. But shouldn’t be the reason when I test in coronas simulator, right?

Mac OSX 10.7.5

strange.

OK, that’s one difference. 

I’ve got Xcode version 5.0 (5A1413) installed but, as you say, it shouldn’t affect testing in the Simulator.

If anything, I’d put my bet on that there might be some quirks with Lion as opposed to Mountain Lion.

Very strange… 

BTW, have you tried to compile for a device and tested it there?

Previously in v1.0 I was able to create an invisible tap-enabled box by setting its setfillcolor alpha to 0 (not its .alpha). Now it appears that this is no longer possible? If i set the fill alpha to anything greagter the 0 it naturally works but how do we now (in v2.0) create invisible tappable areas?

local halfW = display.viewableContentWidth / 2 local halfH = display.viewableContentHeight / 2 local button=display.newRect(halfW,halfH,50,50);button:setFillColor(1,1,1,1) -- setting alpha value to 0 in above setFillColor no longer registers tap event, -- in v1.0 it still registered function button:tap(event)     print("tapped") end button:addEventListener( "tap", button )  

@jacques1

I reported this back in August on this thread:

http://forums.coronalabs.com/topic/38350-objectishittestable-not-working/

It’s on their to-do list  :slight_smile:

[quote name=“jacques1” post=“209770” timestamp=“1381550857”]Previously in v1.0 I was able to create an invisible tap-enabled box by setting its setfillcolor alpha to 0 (not its .alpha). Now it appears that this is no longer possible? If i set the fill alpha to anything greagter the 0 it naturally works but how do we now (in v2.0) create ivisible tappable area?[/quote]I ran into this myself. The trick now is to make the object invisible, but set the ishittestable property to true. It actually works out quicker, but it did catch me out the first time :slight_smile:

@rakoonic

Cool, so i assume by invisible you mean .alpha=0 NOT setFillColor(x,x,x,0)?

I’ll try remember it when i start using 2.0 for finished apps once the bugs are better resolved.

@jacques1

Yes.

Here’s a snippet that shows the problem / bug / workarounds.

-- -- main.lua -- local background = display.newRect(0, 0, 100, 100); background.x = display.contentCenterX; background.y = display.contentCenterY; background.isHitTestable = true; ---- (ex 1) gfx 2.0 fill alpha bug --background:setFillColor(1, 0); ---- (ex 2) this will work --background.alpha = 0; ---- (ex 3) this will also work background.isVisible = false; background:addEventListener( "touch", function(event) print(event.phase, event.x, event.y); end )

My problem resolved since build 2013.2004.

The touch events are working again on Mac OSX 10.7.5

Mac OSX 10.8.5

Graphics 2.0 build 2001

Corona Simulator

That’s a bit weird. I took one of my apps and enabled V1 compatibility mode, and it works as expected.

It’s a business app using widgets though, if that makes a difference…

@romanfischer

We found one issue with touch events and masking that was fixed as of the last daily build.  Is your project using masking?

If you can attach a small bit of sample code we can try to reproduce the issue.

thanks for your quick reply.

well, how about this:

local test = display.newText('hello',0,0,"Arial",16) test.x = display.contentWidth / 2 test.y = display.contentHeight / 2 function touchlistener(event) if event.phase == "began" then print('test') end end test:addEventListener("touch", touchlistener)

doesn’t work in build 2013.2001 nor in build 2013.2000

works in build 2013.1225

did the method change? am I doing something wrong? Doesn’t matter if it’s a text or an image btw…

I’m on Mac OSX

edit: I tried this code in a new blank app

I tested your sample with build 2001 and everything appears to be working normally with the test message going to the console window correctly. It was tested with compatibility mode on and off.

Mac OSX 10.8.5

Corona Graphics 2.0 build 2001

Corona Simulator

I can also confirm that the test code given above works for me as well.

The “test” message is printed in the console when “hello” is tapped.