You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
View: add basic implemntation of dispatchTouchEvent
Some Views block all events going to their descendants, and then synthesize new events themselves. Gtk doesn't allow event synthesization, which makes this quite annoying to deal with. This initial implementation definiely has some problems, for example it seems to cause infinite loops in some cases, however it surprisingly works well enough.
This commit is contained in:
@@ -1075,13 +1075,22 @@ public class View implements Drawable.Callback {
|
||||
}
|
||||
|
||||
private OnTouchListener on_touch_listener = null;
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
|
||||
public boolean onTouchEventInternal(MotionEvent event) {
|
||||
boolean handled = false;
|
||||
if (on_touch_listener != null)
|
||||
handled = on_touch_listener.onTouch(this, event);
|
||||
|
||||
if (!handled)
|
||||
handled = onTouchEvent(event);
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setOnTouchListener(OnTouchListener l) {
|
||||
nativeSetOnTouchListener(widget);
|
||||
on_touch_listener = l;
|
||||
@@ -1206,12 +1215,21 @@ public class View implements Drawable.Callback {
|
||||
|
||||
public native void setBackgroundColor(int color);
|
||||
public native void native_setVisibility(long widget, int visibility, float alpha);
|
||||
|
||||
protected void onVisibilityChanged(View changedView, int visibility) {
|
||||
}
|
||||
|
||||
protected void dispatchVisibilityChanged(View changedView, int visibility) {
|
||||
onVisibilityChanged(changedView, visibility);
|
||||
}
|
||||
|
||||
public void setVisibility(int visibility) {
|
||||
native_setVisibility(widget, visibility, alpha);
|
||||
if ((visibility == View.GONE) != (this.visibility == View.GONE)) {
|
||||
requestLayout();
|
||||
}
|
||||
this.visibility = visibility;
|
||||
dispatchVisibilityChanged(this, visibility);
|
||||
}
|
||||
|
||||
public void setPadding(int left, int top, int right, int bottom) {
|
||||
|
||||
Reference in New Issue
Block a user