I have a display group that has a touch event on it so I can move the object around the screen as it's touched. This group has children that I want to fire custom events from and bubble them up.
the code looks something like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | local group = display.newGroup() local function onTouch(event) if event.phase == "began" then display.getCurrentStage():setFocus(event.target, event.id) elseif event.phase == "moved" then --do something elseif event.phase == "ended" then display.getCurrentStage():setFocus(event.target, nil) end end group:addEventListener("touch", onTouch) local function buttonClicked(event) --here i dispatch another custom event to the groups parent local e = {name="someevent", value="something"} group:dispatchEvent(e) end local my_bn = Button:new() my_bn:addEventListener("customEvent", buttonClicked) group:insert(my_bn) return group |