So all I am trying to do is have some buttons/images/etc inside of a scroll view and detect event.phase == “ended” if they are touched. But from my observations the only thing that ever happens is the “began” phase.
Is this intentional behavior?
As a side note, “tap” seems to work fine. But as soon as I change it to “touch” the “ended” phase never happens.
I have attached some very simple code as an example of what I am trying to do. Would really appreciate some help as I have spent many hours trying to solve this.
local composer = require "composer" local widget = require "widget" local scene = composer.newScene() local function scrollListener( event ) ---[[local phase = event.phase if ( phase == "began" ) then print( "Scroll view was touched" ) elseif ( phase == "moved" ) then print( "Scroll view was moved" ) elseif ( phase == "ended" ) then print( "Scroll view was released" ) end -- In the event a scroll limit is reached... if ( event.limitReached ) then if ( event.direction == "up" ) then print( "Reached bottom limit" ) elseif ( event.direction == "down" ) then print( "Reached top limit" ) elseif ( event.direction == "left" ) then print( "Reached right limit" ) elseif ( event.direction == "right" ) then print( "Reached left limit" ) end end --]] return true end local scrollView = widget.newScrollView( { top = 0, left = 0, width = contentWidth, height = contentHeight, scrollWidth = 1000, scrollHeight = 1000, leftPadding = 0, topPadding = 0, listener = scrollListener } ) function scene:create( event ) local sceneGroup = self.view sceneGroup:insert(scrollView) local function onTouch(event) print("event.phase is: " .. event.phase) if(event.phase == "began") then event.target:takeFocus(event) print("TOUCHED") end if(event.phase == "ended") then print("ENDED") end end local apple = display.newImageRect("apple.png", 100,100) apple.x, apple.y = 110, 110 scrollView:insert(apple) apple:addEventListener("touch", onTouch) scrollView:setScrollHeight(1000) scrollView:setScrollWidth(1000) end -- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is still off screen (but is about to come on screen) elseif ( phase == "did" ) then -- Code here runs when the scene is entirely on screen end end -- hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is on screen (but is about to go off screen) elseif ( phase == "did" ) then -- Code here runs immediately after the scene goes entirely off screen end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view -- Code here runs prior to the removal of scene's view end -- ----------------------------------------------------------------------------------- -- Scene event function listeners -- ----------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ----------------------------------------------------------------------------------- return scene