Patch SDLSurface to allow touch to be intercepted by python application #3157
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
SDLSurface
class 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
)OnInterceptTouchListener
interface and associated methods (setInterceptTouchListener
andonTouch
).SDL3 Bootstrap (
pythonforandroid/bootstraps/sdl3/build/src/patches/SDLSurface.java.patch
)OnInterceptTouchListener
interface 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