mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-04-28 12:17:57 +03:00
handle onClickListener for synthesized MotionEvents
Since synthesized events can't be handled by GTK, we also need to handle gestures by ourself in that case.
This commit is contained in:
parent
db29a02c73
commit
bd83e211d0
3 changed files with 6 additions and 3 deletions
|
@ -132,7 +132,7 @@ void set_up_handle_cache(JNIEnv *env)
|
||||||
handle_cache.view.getScrollY = _METHOD(handle_cache.view.class, "getScrollY", "()I");
|
handle_cache.view.getScrollY = _METHOD(handle_cache.view.class, "getScrollY", "()I");
|
||||||
handle_cache.view.performClick = _METHOD(handle_cache.view.class, "performClick", "()Z");
|
handle_cache.view.performClick = _METHOD(handle_cache.view.class, "performClick", "()Z");
|
||||||
handle_cache.view.onTouchEvent = _METHOD(handle_cache.view.class, "onTouchEvent", "(Landroid/view/MotionEvent;)Z");
|
handle_cache.view.onTouchEvent = _METHOD(handle_cache.view.class, "onTouchEvent", "(Landroid/view/MotionEvent;)Z");
|
||||||
handle_cache.view.onTouchEventInternal = _METHOD(handle_cache.view.class, "onTouchEventInternal", "(Landroid/view/MotionEvent;)Z");
|
handle_cache.view.onTouchEventInternal = _METHOD(handle_cache.view.class, "onTouchEventInternal", "(Landroid/view/MotionEvent;Z)Z");
|
||||||
handle_cache.view.dispatchTouchEvent = _METHOD(handle_cache.view.class, "dispatchTouchEvent", "(Landroid/view/MotionEvent;)Z");
|
handle_cache.view.dispatchTouchEvent = _METHOD(handle_cache.view.class, "dispatchTouchEvent", "(Landroid/view/MotionEvent;)Z");
|
||||||
handle_cache.view.onInterceptTouchEvent = _METHOD(handle_cache.view.class, "onInterceptTouchEvent", "(Landroid/view/MotionEvent;)Z");
|
handle_cache.view.onInterceptTouchEvent = _METHOD(handle_cache.view.class, "onInterceptTouchEvent", "(Landroid/view/MotionEvent;)Z");
|
||||||
handle_cache.view.layoutInternal = _METHOD(handle_cache.view.class, "layoutInternal", "(II)V");
|
handle_cache.view.layoutInternal = _METHOD(handle_cache.view.class, "layoutInternal", "(II)V");
|
||||||
|
|
|
@ -67,7 +67,7 @@ bool view_dispatch_motionevent(JNIEnv *env, WrapperWidget *wrapper, GtkPropagati
|
||||||
}
|
}
|
||||||
ret = false;
|
ret = false;
|
||||||
} else {
|
} else {
|
||||||
ret = (*env)->CallBooleanMethod(env, this, handle_cache.view.onTouchEventInternal, motion_event);
|
ret = (*env)->CallBooleanMethod(env, this, handle_cache.view.onTouchEventInternal, motion_event, (jboolean)(event == NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
if((*env)->ExceptionCheck(env))
|
if((*env)->ExceptionCheck(env))
|
||||||
|
|
|
@ -1076,7 +1076,7 @@ public class View implements Drawable.Callback {
|
||||||
|
|
||||||
private OnTouchListener on_touch_listener = null;
|
private OnTouchListener on_touch_listener = null;
|
||||||
|
|
||||||
public boolean onTouchEventInternal(MotionEvent event) {
|
public boolean onTouchEventInternal(MotionEvent event, boolean handle_gestures) {
|
||||||
boolean handled = false;
|
boolean handled = false;
|
||||||
if (on_touch_listener != null)
|
if (on_touch_listener != null)
|
||||||
handled = on_touch_listener.onTouch(this, event);
|
handled = on_touch_listener.onTouch(this, event);
|
||||||
|
@ -1084,6 +1084,9 @@ public class View implements Drawable.Callback {
|
||||||
if (!handled)
|
if (!handled)
|
||||||
handled = onTouchEvent(event);
|
handled = onTouchEvent(event);
|
||||||
|
|
||||||
|
if (handle_gestures && !handled && event.getAction() == MotionEvent.ACTION_UP)
|
||||||
|
handled = performClick();
|
||||||
|
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue