Touch event on a group with widget inside

Hello,

I create a widget button called " wi "

local  wi=widget.newButton(param)

When I write

wi:addEventListener("tap",function() print(1) end)

or

wi:addEventListener("touch",function() print(1) end)

, the listener works well in the 2 case.

But when the widget is on a group “g”,

local g=display.newGroup() g:insert(wi)

I have that

g:addEventListener("tap",function() print(1) end)

work, but

g:addEventListener("touch",function() print(1) end)

don’t work.

Why ???

Thanks.

no one ?

Hi @yvandotet,

It’s not necessary to add a specific “touch” or “tap” event listener to a widget button (widget.newButton()). The touch functionality it built-in to the widget itself.

https://docs.coronalabs.com/api/library/widget/newButton.html

Best regards,

Brent

I thought I responded to this.

Anyway, widgets have their own built-in touch/tap handling. You should not be adding touch/tap handlers directly to the object like you are. Look at their onEvent, onPress and onRelease options.

As for the inserting in a group, can you produce a little more complete sample, that I can copy/paste to test it?

Thanks

Rob

no one ?

Hi @yvandotet,

It’s not necessary to add a specific “touch” or “tap” event listener to a widget button (widget.newButton()). The touch functionality it built-in to the widget itself.

https://docs.coronalabs.com/api/library/widget/newButton.html

Best regards,

Brent

I thought I responded to this.

Anyway, widgets have their own built-in touch/tap handling. You should not be adding touch/tap handlers directly to the object like you are. Look at their onEvent, onPress and onRelease options.

As for the inserting in a group, can you produce a little more complete sample, that I can copy/paste to test it?

Thanks

Rob