Patch SDLSurface to allow touch to be intercepted by python application#3157
Merged
kuzeyron merged 2 commits intokivy:developfrom Oct 28, 2025
Merged
Patch SDLSurface to allow touch to be intercepted by python application#3157kuzeyron merged 2 commits intokivy:developfrom
kuzeyron merged 2 commits intokivy:developfrom
Conversation
Contributor
|
Ping @kengoon ! Can you refresh this PR? |
Contributor
Author
|
@kuzeyron please what do you mean by refresh? |
Contributor
|
It seems like it needs a rebase + getting the runners to run if it passes the tests. |
Contributor
Author
|
Alright |
Contributor
Author
|
@kuzeyron done |
kuzeyron
approved these changes
Oct 28, 2025
Contributor
|
Thanks! Could you look into where we could place the example codes? I think it's worth having it somewhere as of this PR page disappears and can be problematic to find. |
Contributor
Author
|
@kuzeyron by somewhere do you mean within the repo? |
Contributor
|
Yes, for https://python-for-android.readthedocs.io or if you add a script to the https://github.com/kivy/python-for-android/tree/develop/pythonforandroid/recipes/android/src/android then it would be documented somewhere that is reachable. |
Contributor
Author
|
@kuzeyron alright |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds a feature to intercept touch events in the
SDLSurfaceclass for both the SDL2 and SDL3 bootstraps. It introduces a mechanism to set a customOnInterceptTouchListener, allowing touch events to be handled before further processing.Touch Event Handling Enhancements
SDL2 Bootstrap (
pythonforandroid/bootstraps/sdl2/build/src/patches/SDLSurface.java.patch)OnInterceptTouchListenerinterface and associated methods (setInterceptTouchListenerandonTouch).SDL3 Bootstrap (
pythonforandroid/bootstraps/sdl3/build/src/patches/SDLSurface.java.patch)OnInterceptTouchListenerinterface and methods as SDL2, ensuring consistency.This feature is especially useful for forwarding touch events to Android native widgets rendered behind a Kivy widget, for example, when these metadata settings are applied:
and a native widget is inserted behind the Kivy widget:
A practical example is the kivy-gmap project, which uses Android's native Google MapView behind a Kivy widget.
This capability was also present in older p4a toolchains. See this legacy implementation for reference.
Screen_Recording_20250516_010309.mp4