Skip to content

Conversation

@kengoon
Copy link
Contributor

@kengoon kengoon commented Nov 24, 2025

This pull request introduces a new module, android.touch, to the pythonforandroid recipes, providing utilities for intercepting touch events on the Android SDL surface from Python code. The main additions are a bridge class for hooking into the Android touch interception mechanism and a convenience API for registering/unregistering global touch listeners with hit-testing against Kivy widgets.

Touch interception API

  • Added OnInterceptTouchListener, a Python bridge for the Android Java interface SDLSurface.OnInterceptTouchListener, allowing Python callables to intercept and optionally consume touch events before they reach the normal event dispatch pipeline.
  • Added TouchListener, a helper class to register/unregister a global touch intercept listener on the app's SDL surface, with logic to hit-test against a specified Kivy target_widget and consume touches only when appropriate.

Hit-testing and event handling

  • Implemented a hit-testing routine in TouchListener._pick to recursively select the deepest widget under the touch point, using Kivy's widget tree and coordinate transformations.
  • The listener callback in TouchListener converts Android touch coordinates to Kivy's coordinate system and intercepts touches only when the target widget is hit and no other widget is found under the touch.

API documentation and usage notes

  • Included detailed docstrings and usage

@kuzeyron kuzeyron merged commit ad8f902 into kivy:develop Nov 25, 2025
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants