kivy/kivy — pull request #1502 by matham (2013-09-14 21:53:42+00:00)
Title: Add touch argument to on_release events so that we can find coordinates of the touch when it was released.

In many programs, a action is performed when a button is released if the touch is still on top of the button. This is not simple to currently do with Button.

The simplest way is to listen to on_touch_up events, and if it occurs while still on the button do the action. The problem is that button implements on_release so that you don't have to listen to on_touch_up, so this makes it a bit redundant.

I could add a option so that if selected, on_release will only be dispatched if the release collided. But I think a on_release event should always be dispatched, because you might need to know that the button was released, even if you're not going to a do action A. E.g. to know which state you're in. Or, if the release didn't collide, you might have to do something else.

I think the best solution is to add a touch argument to on_release so that a user can decide what to do in response to the on_release by checking touch.pos in the argument.

The only problem is that this breaks compatibility. However, I think any decent program should have a *largs parameter anyway for all the functions that are called on dispatch, for future compatibility. In fact we might want to add this to the the http://kivy.org/docs/guide/bestpractices.html section. This patch adds this feature, and adds *largs to all the on_release functions.