- Kivy dispatches any touch event on the app to the root widget class.
- A touch event could be any of the following
- Down event
- Up event
- Move event
- In Kivy, the root widget passes the event to all of its children while the children can pass the event to further down to their children.
- This way, it is not only the widget within whose physical boundaries the touch event occurred receive the event. Other widgets also receive the touch event.
- When a touch event occurs it is first received by one of the on_touch_xxx() handlers of the root widget.
- Once received an event can be digested by the Kivy widget meaning it need not be propagated to the children or it can be propagated to the children.
from kivy.uix.button import Button
from kivy.app import App
# Customized button
# Handle touch - an up event
def on_touch_down(self, touch):
self.text = "Touch down"
# digest the event
# Handle touch - a down event
def on_touch_up(self, touch):
self.text = "Touch me...."
# touch is on the button...do not want to send this event any further
# App class
appButton = AppButton(text = "Touch me...")
if __name__ == '__main__':