Hi @jeremyapplebaum12,
I just tested some basic code using :setFocus() as @SP Technolab suggests, and I’m getting the expected result when I drag my finger off the screen edge (on iPhone at least). So, something else must be going on in your setup or listeners or conditional logic.
Here’s the code I used:
[lua]
local testRect2 = display.newRect( display.contentCenterX,display.contentCenterY,display.contentWidth,display.contentHeight)
testRect2:setFillColor( 0.3 )
local testRect = display.newRect( display.contentCenterX-50,display.contentCenterY,display.contentWidth-100,display.contentHeight)
testRect:setFillColor( 1,0,0 )
local function objectTouched( event )
if event.phase == “began” then
display.getCurrentStage():setFocus( event.target )
testRect:setFillColor( 1 )
elseif event.phase == “ended” or event.phase == “cancelled” then
display.getCurrentStage():setFocus( nil )
testRect:setFillColor( 1,0,0 )
end
return true
end
local function object2Touched( event )
if event.phase == “began” then
display.getCurrentStage():setFocus( event.target )
testRect2:setFillColor( 0,0,1 )
elseif event.phase == “ended” or event.phase == “cancelled” then
display.getCurrentStage():setFocus( nil )
testRect2:setFillColor( 0.3 )
end
return true
end
testRect:addEventListener( “touch”, objectTouched )
testRect2:addEventListener( “touch”, object2Touched )
[/lua]