button help

Is it possible to make it so that if you press a button but dont release it and just drag your finger off it, it has the same effect as releasing it. For example, I am using the code

local function presslevels (event)
 if event.phase == "began" then
 levelsbtn:setTextColor(247,117,9)
 elseif event.phase == "ended" or event.phase == "canceled" then
 levelsbtn:setTextColor(0,00,0)
 end
end

when I press and release the button, the text changes colour and then changes back again. However, if press it and then drag my finger and away, the text stays the new colour. [import]uid: 116264 topic_id: 21171 reply_id: 321171[/import]

Try changing;
[lua]elseif event.phase == “ended” or event.phase == “canceled” then[/lua]

To;

[lua]elseif event.phase == “ended” or event.phase == “canceled” or event.phase == “moved” then[/lua]

Peach :slight_smile: [import]uid: 52491 topic_id: 21171 reply_id: 83913[/import]

Oh - OR - you may just want to use “tap” rather than “touch” - that way you don’t have to play with event phases. [import]uid: 52491 topic_id: 21171 reply_id: 83914[/import]

See this : http://developer.anscamobile.com/forum/2012/01/24/what-do-when-touch-target-lost [import]uid: 84637 topic_id: 21171 reply_id: 83987[/import]