touch event passes thru despite returning true

In my game I have a black background rectangle that covers the entire screen, then various active elements in front of it. I have a certain menu that pops up that should go away if the user taps anywhere outside it. My touch event handler for the menu always returns true. Nevertheless, the event is getting away and is being seen by the background rectangle as well. Or if I use Runtime instead of the background rectangle is my handler of last resort, I still see the event, even though the menu handler has handled it. I can set a breakpoint on the “return true” statement and see that it is executed.

Having inherited some legacy code, I’m using a legacy version rather than change all the color numbers to meet the new graphics standard. I’m using version 2012.971 (2012.11.15) running on Mac OS 10.7.5.

Were there known bugs back then that could cause this kind of problem? Any good workarounds? (I can think of some ugly ones, but I’d rather find a nice one)

Thanks,

Ken

handler code follows:

function miniSelectorTouch(event, menu, isFirst) &nbsp; local d = math.floor((event.y - yLevels) / menuScale) + 1 &nbsp; if isFirst then firstMenuPick = d end &nbsp; if event.phase == "moved" then &nbsp; elseif event.phase == "ended" then &nbsp; &nbsp; local oldTop = menu.sq.top &nbsp; &nbsp; if inMenu(event) and d \<= depth then &nbsp; &nbsp; &nbsp; menu.sq.top = d &nbsp; &nbsp; &nbsp; redrawSquare(menu.sq) &nbsp; &nbsp; &nbsp; miniDepthChange(menu.sq, oldTop) &nbsp; &nbsp; end &nbsp; end &nbsp; return true end &nbsp;

Hi there,

Not focussed enough to go over your code tonight, but 2 things:

1 - is it possible that a “began” phase trigger the menu to disappear, after which the “ended” triggers the black rectangle? Make sure to print out event phase and target IDs and touch IDs to make sure.

2- don’t forget “isHitTestable = true”. Not sure it should come into play here, but I remember it fixing an error I wrestled with once.

Also, print out statements at various points to see which steps happen first (like print(“true returned NOW”)

Hope you get it sorted!

Cheers,

Thomas

Looking at your code Thomas may be on to something.  But also consider that every “tap” event also generates touch events.  Are you sure the underlying code isn’t getting the other handler?

Hi there,

Not focussed enough to go over your code tonight, but 2 things:

1 - is it possible that a “began” phase trigger the menu to disappear, after which the “ended” triggers the black rectangle? Make sure to print out event phase and target IDs and touch IDs to make sure.

2- don’t forget “isHitTestable = true”. Not sure it should come into play here, but I remember it fixing an error I wrestled with once.

Also, print out statements at various points to see which steps happen first (like print(“true returned NOW”)

Hope you get it sorted!

Cheers,

Thomas

Looking at your code Thomas may be on to something.  But also consider that every “tap” event also generates touch events.  Are you sure the underlying code isn’t getting the other handler?