event propagation

Hi There,

I will put my question straightforward. I understand that events are to be passed to underlying objects in cases where “return true” closing statement is unseen. However,

What about overlying objects that are just created. I have a button, which on press, creates a bunch of overlying objects. Now as you can see, all this happens before I close the first listener function. Hence I have a situation where the “tap” event actually comes over to overlapped objects.

Hi @appu333,

Can you create these objects on the “release” (ended) state? Or create them after a 10 ms timer, so the button events are all handled and done?

Brent

Hi Brent,

I actually put them in onrelease listener, was just quoted it as onpress listener. Well, which one it may be in, the “tap” event persist until somewhere it is returned true.

Let me put the ~code.

listener function

    create a rect

    create a tableview

    return true

end

button = {

   on_release = listener

}

Now in this case, I cannot stop the “tap” being propagated to rect/table view, unless I create something like a “rect wall” which absorbs the “tap” and then is removed. Is that a nice way?

Hi @appu333,

You may be able to conditionally check whether the tap event is associated with the button ID or not. If you’re getting a response on the overlaying objects, but the ID of the event.target is the button, then you can just return false and skip any processing of that event, because it occurs on the new objects, not the button.

Brent

  Hi Brent,

I did it so but it don’t solve the issue.

function button_listener(event)

  thisButton =  event.target

  function rect_listener(event)

     – here is the issue where the “tap” event is automatically intruded

     if(event.target == thisButton) then ignore  else  do stuff  end

  end

  create a rect

  rect:addeventlistener(“tap”, rect_listener)

  create a table view  

end

local button = {

   on_release = button_listener

  }

As you can see, if in the tap event listener for the rect, event.target is the rect and not the button. I want that rect to get tap events and there are listener actions. But our “tap” event first hit button, and then hit “rect”. it is not possible to stop tap event hitting rect, other than putting another object even on top of it. after hitting rect, event.target is rect and hence the same as normal rect hit

But thanks for your suggestion. Now I manage it all by creating a rect object, just before button listener close, so that it appear on top of everything and it is removed with removeself upon hit…

Thank you again,

Appu.

Hi @appu333,

Can you create these objects on the “release” (ended) state? Or create them after a 10 ms timer, so the button events are all handled and done?

Brent

Hi Brent,

I actually put them in onrelease listener, was just quoted it as onpress listener. Well, which one it may be in, the “tap” event persist until somewhere it is returned true.

Let me put the ~code.

listener function

    create a rect

    create a tableview

    return true

end

button = {

   on_release = listener

}

Now in this case, I cannot stop the “tap” being propagated to rect/table view, unless I create something like a “rect wall” which absorbs the “tap” and then is removed. Is that a nice way?

Hi @appu333,

You may be able to conditionally check whether the tap event is associated with the button ID or not. If you’re getting a response on the overlaying objects, but the ID of the event.target is the button, then you can just return false and skip any processing of that event, because it occurs on the new objects, not the button.

Brent

  Hi Brent,

I did it so but it don’t solve the issue.

function button_listener(event)

  thisButton =  event.target

  function rect_listener(event)

     – here is the issue where the “tap” event is automatically intruded

     if(event.target == thisButton) then ignore  else  do stuff  end

  end

  create a rect

  rect:addeventlistener(“tap”, rect_listener)

  create a table view  

end

local button = {

   on_release = button_listener

  }

As you can see, if in the tap event listener for the rect, event.target is the rect and not the button. I want that rect to get tap events and there are listener actions. But our “tap” event first hit button, and then hit “rect”. it is not possible to stop tap event hitting rect, other than putting another object even on top of it. after hitting rect, event.target is rect and hence the same as normal rect hit

But thanks for your suggestion. Now I manage it all by creating a rect object, just before button listener close, so that it appear on top of everything and it is removed with removeself upon hit…

Thank you again,

Appu.