Hello, I have a rectangle inside a scrollview and when I touch the rectangle, another rectangle appears and I add a tap event on it, I would like to touch the rectangle in it, but my touch event works, but the object does not disappear.
local button function scene:create( event ) local sceneGroup = self.view scrollView = widget.newScrollView( { top = display.contentHeight - display.contentHeight \* 55 / 100, left = 0, width = display.contentWidth, height = display.contentHeight \* 55 / 100, scrollWidth = 600, horizontalScrollDisabled = true, scrollHeight = 1300, listener = scrollListener } ) sceneGroup:insert(scrollView) for i=1, 86 do cards[#cards + 1] = { name = 'card'..i..'.png', x = 8 + ( i - 1 ) % 4 \* 76, y = 8 + ( mFloor( ( i - 0.5 ) / 4 ) \* 98 ), w = (display.contentWidth - 40) / 4, h = 90 } end function cardRemove(event) button:removeSelf() button = nil print("Toquei no Botão!") print(button) -- Return nil. end local function tap( self, event ) if lastTappedCard then myCardsRef[lastTappedCard].alpha = 1 if button ~= nil then button:removeSelf() button = nil end end myCardsRef[self].alpha = 0.5 button = display.newRect(sceneGroup,myCardsRef[self].x + myCardsRef[self].width \* .5,myCardsRef[self].y + myCardsRef[self].height \* .5, 60, 30) button:setFillColor(0,0,0) getButton = button scrollView:insert(button) lastTappedCard = self button:addEventListener("tap",cardRemove) end for index = 1, #cards do local card = display.newRect(sceneGroup,cards[index].x,cards[index].y,cards[index].w,cards[index].h) card.anchorX = 0 card.anchorY = 0 card:setFillColor( 1, 0, 0 ) card.tap = tap card:addEventListener( "tap" ) scrollView:insert( card ) myCardsRef[card] = card end end