Skip to content

Commit b09db57

Browse files
committed
add the possibility to intercept touches in SDLSurfaceView (same as ViewGroup).
1 parent 335adb9 commit b09db57

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/src/org/renpy/android/SDLSurfaceView.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ private void printConfig(EGL10 egl, EGLDisplay display,
270270
private int[] mValue = new int[1];
271271
}
272272

273+
public interface OnInterceptTouchListener {
274+
boolean onTouch(MotionEvent ev);
275+
}
276+
277+
private OnInterceptTouchListener mOnInterceptTouchListener = null;
278+
273279
// The activity we're a part of.
274280
private static PythonActivity mActivity;
275281

@@ -938,12 +944,20 @@ public int swapBuffers() {
938944
private static final int INVALID_POINTER_ID = -1;
939945
private int mActivePointerId = INVALID_POINTER_ID;
940946

947+
public void setInterceptTouchListener(OnInterceptTouchListener listener) {
948+
this.mOnInterceptTouchListener = listener;
949+
}
950+
941951
@Override
942952
public boolean onTouchEvent(final MotionEvent event) {
943953

944954
if (mInputActivated == false)
945955
return true;
946956

957+
if (mOnInterceptTouchListener != null)
958+
if (mOnInterceptTouchListener.onTouch(event))
959+
return false;
960+
947961
int action = event.getAction() & MotionEvent.ACTION_MASK;
948962
int sdlAction = -1;
949963
int pointerId = -1;

0 commit comments

Comments
 (0)