Grabbing touch events

There are some moments or areas where we do not want the touch performed in the same way. Therefore, we can grab some inputs to give them special treatment.

Getting ready

We will continue working with the touch profile, so it could be useful to review the previous recipes for a deeper understanding, also we will use the same KV file with the common button and label widgets whereby you will find a detailed explanation of the KV file in the recipe Recognizing touch shapes.

How to do it…

This recipe following the next steps:

  1. In the KV file, define a button and a empty label:
    <MyW>:
        Button:
            id: button1
            pos: 0,0
            text: 'Hello'
    
        Label:
            id: label1
            pos: 200, 200
            text: ''
  2. In the class of the widget in the Python code, we need to override the ...

Get Kivy Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.