ended event phase not fired on quick drags on iphone

I basically have a listener on a widget.button ( doubt that it being a widget button matters, but i’ll mention that anyways) where it does stuff on pressed/moved/release events

Normally everything behaves as it should with all of the events being fired properly and everything working just dandy, but it’s possible to basically touch the button, and then quickly drag it and let it go, and then ended event does not get fired, which makes it seem like you are still holding the button yet you already let it go

This does not happen in simulator, not when built on android, but only on ios/xcode simulator

In the press phase i do have
display.getCurrentStage():insert(event.target)
display.getCurrentStage():setFocus(event.target)
and in the ended phase
display.getCurrentStage():setFocus(nil)

I tried setting the event.target.isFocus = true in press and false in ended as some examples have it, but that didn’t help

I even tried running with with printouts for every event to make sure there’s nothing silly going on, yet everything works as i described

sample of it working (these are logs from running on xcode sim):
2013-01-21 11:28:28.735 AM : Phase press x 280 y 90
2013-01-21 11:28:29.154 AM : Phase moved x 272 y 79
2013-01-21 11:28:29.172 AM : Phase moved x 272 y 78
2013-01-21 11:28:29.188 AM : Phase moved x 272 y 76
2013-01-21 11:28:29.206 AM : Phase moved x 271 y 72
2013-01-21 11:28:29.221 AM : Phase moved x 267 y 67
2013-01-21 11:28:29.244 AM : Phase moved x 262 y 62
2013-01-21 11:28:29.255 AM : Phase moved x 258 y 57
2013-01-21 11:28:29.277 AM : Phase moved x 255 y 55
2013-01-21 11:28:29.311 AM : Phase moved x 254 y 54
2013-01-21 11:28:30.191 AM : Phase moved x 253 y 53
2013-01-21 11:28:30.224 AM : Phase moved x 253 y 51
2013-01-21 11:28:30.257 AM : Phase moved x 253 y 50
2013-01-21 11:28:30.358 AM : Phase moved x 253 y 49
2013-01-21 11:28:30.377 AM : Phase moved x 252 y 51
2013-01-21 11:28:30.391 AM : Phase moved x 236 y 66
2013-01-21 11:28:30.410 AM : Phase moved x 200 y 96
2013-01-21 11:28:30.425 AM : Phase moved x 159 y 132
2013-01-21 11:28:30.444 AM : Phase moved x 101 y 180
2013-01-21 11:28:30.458 AM : Phase moved x 65 y 209
2013-01-21 11:28:30.477 AM : Phase release x 46 y 224

Sample of it breaking (same logs from xcode sim):

2013-01-21 11:28:35.328 AM : Phase press x 280 y 90
2013-01-21 11:28:35.423 AM : Phase moved x 272 y 93
2013-01-21 11:28:35.440 AM : Phase moved x 272 y 91
2013-01-21 11:28:35.456 AM : Phase moved x 271 y 87
2013-01-21 11:28:35.474 AM : Phase moved x 269 y 83
2013-01-21 11:28:35.490 AM : Phase moved x 266 y 78
2013-01-21 11:28:35.506 AM : Phase moved x 262 y 73
2013-01-21 11:28:35.523 AM : Phase moved x 258 y 67
2013-01-21 11:28:35.544 AM : Phase moved x 253 y 64
2013-01-21 11:28:35.557 AM : Phase moved x 251 y 61
2013-01-21 11:28:35.576 AM : Phase moved x 248 y 58
2013-01-21 11:28:35.590 AM : Phase moved x 247 y 58
2013-01-21 11:28:35.690 AM : Phase moved x 247 y 57
2013-01-21 11:28:35.709 AM : Phase moved x 247 y 56
2013-01-21 11:28:35.724 AM : Phase moved x 246 y 55
2013-01-21 11:28:35.743 AM : Phase moved x 246 y 52
2013-01-21 11:28:35.757 AM : Phase moved x 245 y 49
2013-01-21 11:28:35.777 AM : Phase moved x 244 y 47
2013-01-21 11:28:35.790 AM : Phase moved x 243 y 45
2013-01-21 11:28:35.824 AM : Phase moved x 242 y 44
2013-01-21 11:28:36.576 AM : Phase moved x 242 y 42
2013-01-21 11:28:36.593 AM : Phase moved x 241 y 43
2013-01-21 11:28:36.610 AM : Phase moved x 241 y 44
2013-01-21 11:28:36.626 AM : Phase moved x 241 y 46
2013-01-21 11:28:36.727 AM : Phase moved x 241 y 47
2013-01-21 11:28:36.760 AM : Phase moved x 241 y 46
2013-01-21 11:28:36.777 AM : Phase moved x 241 y 45
2013-01-21 11:28:36.794 AM : Phase moved x 243 y 44
2013-01-21 11:28:36.810 AM : Phase moved x 244 y 42
2013-01-21 11:28:36.827 AM : Phase moved x 246 y 41
2013-01-21 11:28:36.861 AM : Phase moved x 247 y 39
2013-01-21 11:28:36.910 AM : Phase moved x 249 y 37
2013-01-21 11:28:36.927 AM : Phase moved x 249 y 36
2013-01-21 11:28:36.961 AM : Phase moved x 251 y 36
2013-01-21 11:28:37.028 AM : Phase moved x 252 y 35
2013-01-21 11:28:37.044 AM : Phase moved x 246 y 39
2013-01-21 11:28:37.061 AM : Phase moved x 222 y 56
2013-01-21 11:28:37.078 AM : Phase moved x 185 y 76
2013-01-21 11:28:37.095 AM : Phase moved x 127 y 107

(this is when the object was released and no ended event was fired)
What can be the reasons for the ended event not to get fired on iOS?

Any help will be appreciated
[import]uid: 121569 topic_id: 35159 reply_id: 335159[/import]

Can you post your touch function code? [import]uid: 41884 topic_id: 35159 reply_id: 139754[/import]

Hi @alexgloushenkov,
Would it be a lot of effort for you to test this -not- on a widget button, but rather just on the screen/stage by itself? If you can isolate it to a system-wide type of behavior, it would be a bit easier to diagnose.

Thanks,
Brent Sorrentino [import]uid: 200026 topic_id: 35159 reply_id: 139757[/import]

Hi @alexgloushenkov,
Would it be a lot of effort for you to test this -not- on a widget button, but rather just on the screen/stage by itself? If you can isolate it to a system-wide type of behavior, it would be a bit easier to diagnose.

Thanks,
Brent Sorrentino
Took a bit of effort into making it into a sprite instead of a widget button and the problem seems to have gone away, although I would still kind of prefer to have it as a widget button (sort of, since its missing some functionality that i’d like, such as being able to change index/over frames after creation) without having to redo my logic around sprites, although it seems like I’ll have to?

[import]uid: 121569 topic_id: 35159 reply_id: 139770[/import]

Hello again,
Can you post a bit of your widget code, where you set up the widget? I might discern something more specific from that… Thanks!

Brent [import]uid: 200026 topic_id: 35159 reply_id: 139869[/import]

This is going to be a little cut off minus the important parts but sure, this was back in widget form:

[code]
function dostuff(event)
print("Phase " … event.phase … " x " … event.target.x … " y " … event.target.y)
local tar = event.target
tar:setReferencePoint(display.CenterReferencePoint)

if event.phase == “press” then
tar.x = event.x
tar.y = event.y
display.getCurrentStage():insert(tar)
display.getCurrentStage():setFocus(tar)
tar.isFocus = true
elseif tar.isFocus and event.phase == “moved” then
tar.x = event.x
tar.y = event.y
if tar.x > 0 and tar.x < 320 and tar.y > 0 and tar.y < 480 then
– This is just for checking within the bounds of some iphone, i never actually drag out of the screen area for this to be the issue
do some unrelated logic here
end
elseif tar.isFocus and event.phase == “released” or event.phase == “cancelled” then
display.getCurrentStage():setFocus(nil)
tar.isFocus = false
– do some more unrelated logic here
end
return true
end
[/code] [import]uid: 121569 topic_id: 35159 reply_id: 139937[/import]

Can you post your touch function code? [import]uid: 41884 topic_id: 35159 reply_id: 139754[/import]

Hi @alexgloushenkov,
Would it be a lot of effort for you to test this -not- on a widget button, but rather just on the screen/stage by itself? If you can isolate it to a system-wide type of behavior, it would be a bit easier to diagnose.

Thanks,
Brent Sorrentino [import]uid: 200026 topic_id: 35159 reply_id: 139757[/import]

Hi @alexgloushenkov,
Would it be a lot of effort for you to test this -not- on a widget button, but rather just on the screen/stage by itself? If you can isolate it to a system-wide type of behavior, it would be a bit easier to diagnose.

Thanks,
Brent Sorrentino
Took a bit of effort into making it into a sprite instead of a widget button and the problem seems to have gone away, although I would still kind of prefer to have it as a widget button (sort of, since its missing some functionality that i’d like, such as being able to change index/over frames after creation) without having to redo my logic around sprites, although it seems like I’ll have to?

[import]uid: 121569 topic_id: 35159 reply_id: 139770[/import]

Hello again,
Can you post a bit of your widget code, where you set up the widget? I might discern something more specific from that… Thanks!

Brent [import]uid: 200026 topic_id: 35159 reply_id: 139869[/import]

This is going to be a little cut off minus the important parts but sure, this was back in widget form:

[code]
function dostuff(event)
print("Phase " … event.phase … " x " … event.target.x … " y " … event.target.y)
local tar = event.target
tar:setReferencePoint(display.CenterReferencePoint)

if event.phase == “press” then
tar.x = event.x
tar.y = event.y
display.getCurrentStage():insert(tar)
display.getCurrentStage():setFocus(tar)
tar.isFocus = true
elseif tar.isFocus and event.phase == “moved” then
tar.x = event.x
tar.y = event.y
if tar.x > 0 and tar.x < 320 and tar.y > 0 and tar.y < 480 then
– This is just for checking within the bounds of some iphone, i never actually drag out of the screen area for this to be the issue
do some unrelated logic here
end
elseif tar.isFocus and event.phase == “released” or event.phase == “cancelled” then
display.getCurrentStage():setFocus(nil)
tar.isFocus = false
– do some more unrelated logic here
end
return true
end
[/code] [import]uid: 121569 topic_id: 35159 reply_id: 139937[/import]

Hi Alex,
Sorry for the delayed response. Looking at your code, I see one possible issue. On line 20, you have one of the “event.phase” conditions as “released”, but in the widget button documentation, the phase should be “release” (without the “d”).
http://docs.coronalabs.com/api/library/widget/newButton.html

Can you try fixing that and then let me know what happens? It might not solve the issue, but try it and see.

Thanks,
Brent [import]uid: 200026 topic_id: 35159 reply_id: 140826[/import]

Hi,

I wasn’t directly copy pasting every single line from my code, so that was actually a typo, and it was actually the proper spelling in my widget code (If it wasn’t, I would never get my event to fire at all, instead of just sometimes, and my printout of the event.phase would still print it out in the correct spelling even if it did not fire)

I do believe it may be related to implementation of the widgets themselves, but that’s just my best guess, as I don’t see any other reasonable explanation (perhaps something to do with android keeping a queue of all of the events that happened, so it goes through them, while ios just does them as they happen and can miss some if they happen in quick succession or something like that, although don’t know why it would affect widget buttons and not anything else without seeing the widget code)

Either way I’m back to using sprites now, although am still curious as to why this happens [import]uid: 121569 topic_id: 35159 reply_id: 140900[/import]

Hi Alex,
Sorry for the delayed response. Looking at your code, I see one possible issue. On line 20, you have one of the “event.phase” conditions as “released”, but in the widget button documentation, the phase should be “release” (without the “d”).
http://docs.coronalabs.com/api/library/widget/newButton.html

Can you try fixing that and then let me know what happens? It might not solve the issue, but try it and see.

Thanks,
Brent [import]uid: 200026 topic_id: 35159 reply_id: 140826[/import]

Hi,

I wasn’t directly copy pasting every single line from my code, so that was actually a typo, and it was actually the proper spelling in my widget code (If it wasn’t, I would never get my event to fire at all, instead of just sometimes, and my printout of the event.phase would still print it out in the correct spelling even if it did not fire)

I do believe it may be related to implementation of the widgets themselves, but that’s just my best guess, as I don’t see any other reasonable explanation (perhaps something to do with android keeping a queue of all of the events that happened, so it goes through them, while ios just does them as they happen and can miss some if they happen in quick succession or something like that, although don’t know why it would affect widget buttons and not anything else without seeing the widget code)

Either way I’m back to using sprites now, although am still curious as to why this happens [import]uid: 121569 topic_id: 35159 reply_id: 140900[/import]