Using the mouse
This recipe will teach you how to use the first kind of input, probably the most used, the mouse. We will consider the mouse input as a touch event, so the (x, y) position of the touch (0-1 range) will be scaled to the window size (width/height) and dispatched to the following:
on_touch_down: An event is fired when a touch down event is initiated. Subsequently, the respective widget's
on_touch_down()
method is called.on_touch_move: An event is fired when a touch event moves (changes location). Subsequently, the respective widget's
on_touch_move()
method is called.on_touch_up: An event is fired when a down event is released (terminated). Subsequently, the respective widget's
on_touch_up()
method is called.
Getting ready
In this recipe, we will use the Kv language for the design of the widgets, so you will need to be familiar with the language or have completed the previous chapter. Also, this recipe will use the common Button
widget for reference.
How to do it…
Follow the steps...