Blocking touch events behind a series of buttons

Hi,
I was hoping someone could give me some advice or point me in the right direction on this.
I have a scrollview with a game map in it.
When a player selects a tile, a series of context relevant buttons pop up in a row along the top of the screen in it’s own display group.

When I select one of these buttons, the button works and does what I intend, but it also selects the tile beneath the button that is in my scrollview display group and that can sometimes result in the same action being performed on that tile, but also, it shifts the focus from the tile that the player selected in the first place.

Ideally, I wish I could should create an invisible rectangle behind the button group and have that block touch events in that area to the scrollview

Each tile in the scrollview has it’s own touch listener, so if I did something like killing all the touch listeners except my buttons, then the player wouldn’t be able to choose a different tile in the scrollview if they want to, and I guess I would have to redraw the entire scrollview with touch listeners again, to get them working again.

anyway, any advice on this problem would be great. [import]uid: 170004 topic_id: 35265 reply_id: 335265[/import]

Hi there,

put ‘return true’ at the end of the touch events and that would stop the touch replicating to everything else under the buttons you are pressing.

http://developer.coronalabs.com/content/application-programming-guide-event-handling

“Hit events propagate until they are handled. You can stop propagation to the next object (all listeners of the current object still get the event) by telling the system that the event was handled. This boils down to making a listener return true. If at least one of the listeners of the current object returns true, event propagation ends; the next object will not get the event.” [import]uid: 62706 topic_id: 35265 reply_id: 140206[/import]

Hi Crafty

thanks for the tip, return true seems to have fixed the problem with applying the effect to the tile that happens to be beneath the button pressed.

It still selects that tile under the button however, and I don’t want whatever random tile happens to be below the button to get selected, so It seems like I still need to mask the area underneath the buttons. [import]uid: 170004 topic_id: 35265 reply_id: 140208[/import]

Hmm, have you mixed touch and tap events by any chance?

Like the button has a tap and the tiles have a touch event?

If so, give this a read: http://coronageek.com/1162/handling-corona-sdk-tap-events-vs-touch-events/

Basically creating either a tap/touch function for the button with just ‘return true’

[import]uid: 62706 topic_id: 35265 reply_id: 140217[/import]

Hey Crafty
That article was exactly what I needed. I did in fact think tap was just a type of touch.
I replaced the tap with touch and that solved the issue I was having, but then I couldn’t drag the scrollview window.

I found this http://www.coronalabs.com/blog/2012/01/10/new-more-flexible-scrollview-widget/ and was able to implement it. Every thing works like it should now.

thanks again [import]uid: 170004 topic_id: 35265 reply_id: 140248[/import]

No problem, glad its all working for you :slight_smile: [import]uid: 62706 topic_id: 35265 reply_id: 140249[/import]

Hi there,

put ‘return true’ at the end of the touch events and that would stop the touch replicating to everything else under the buttons you are pressing.

http://developer.coronalabs.com/content/application-programming-guide-event-handling

“Hit events propagate until they are handled. You can stop propagation to the next object (all listeners of the current object still get the event) by telling the system that the event was handled. This boils down to making a listener return true. If at least one of the listeners of the current object returns true, event propagation ends; the next object will not get the event.” [import]uid: 62706 topic_id: 35265 reply_id: 140206[/import]

Hi Crafty

thanks for the tip, return true seems to have fixed the problem with applying the effect to the tile that happens to be beneath the button pressed.

It still selects that tile under the button however, and I don’t want whatever random tile happens to be below the button to get selected, so It seems like I still need to mask the area underneath the buttons. [import]uid: 170004 topic_id: 35265 reply_id: 140208[/import]

Hmm, have you mixed touch and tap events by any chance?

Like the button has a tap and the tiles have a touch event?

If so, give this a read: http://coronageek.com/1162/handling-corona-sdk-tap-events-vs-touch-events/

Basically creating either a tap/touch function for the button with just ‘return true’

[import]uid: 62706 topic_id: 35265 reply_id: 140217[/import]

Hey Crafty
That article was exactly what I needed. I did in fact think tap was just a type of touch.
I replaced the tap with touch and that solved the issue I was having, but then I couldn’t drag the scrollview window.

I found this http://www.coronalabs.com/blog/2012/01/10/new-more-flexible-scrollview-widget/ and was able to implement it. Every thing works like it should now.

thanks again [import]uid: 170004 topic_id: 35265 reply_id: 140248[/import]

No problem, glad its all working for you :slight_smile: [import]uid: 62706 topic_id: 35265 reply_id: 140249[/import]

Thanks Deano - exactly what I needed as well [import]uid: 32462 topic_id: 35265 reply_id: 141112[/import]

Thanks Deano - exactly what I needed as well [import]uid: 32462 topic_id: 35265 reply_id: 141112[/import]