Buttons - Graphics 2.0

Because the group needs to be moveable. As a group. Dropping images into a display group limits what you can do, in many ways.

You cannot move the group. The group cannot receive drag and drop/touch related events. Snapshots can be moved.

I’ll trade G1’s more masking and more textures (to replicate certain effects) and unpredictable eventing over the loss of scaling and moving groups (via buttons).

Group’s are  movable.  They have a .x and .y and can be moved just like anything else.  And as far as touch handlers, you can.  You can either assign a touch handler to the group in which case the touch fall through to all objects in the group, or if you need to touch empty space inside the group, then you can put an invisible rect the size of the area that needs touched and put the touch handler on it after setting the rect’s .isHitTestable to true.

Rob

Touch events normally do not fall through buttons in G2.

That may not be the only widget. In G1, buttons that were disabled also prevented all event propagation.

You can add a tapListener and a touchListener to a group or a button in that group.

Only tap is recognized on the button and touch never falls through from the button, enabled or not.

It’s so hard to try every possible scenario.

Widget buttons consume touch events and generate release, event and press events depending on options you pass.  The touch event is handled by the object and will not propagate on.  It doesn’t look like we mess with the tap event that is also generated so that will fall through.

This should be no different between G1 and G2.

Rob

In addition to groups having X and Y (thanks for the correction), when they are an event.target, they lose those values as event.target

local mygroup = display.newGroup() mygroup:insert(buttonAt10x20y) print(mygroup.x,mygroup.y) -- outputs 10,20 mygroup:addEventListeners("touch",function(e) print(e.target.x,e.target.y) -- outputs 0,0 end)

which is why I thought that. If you have a button as your largest object in the group, you probably lose the ability to detect touch events. You can’t forward those press/release/event from the button so…oh well.