feat: add ability to pass touch event thru parent view (#135)

* [WIP] feat: enhance hit-testing support
* refactor(ios): update passthroughParent logic as per reqs
* refactor: move isPassthroughParentEnabled to LayoutBase
* refactor: renames
This commit is contained in:
Manol Donev
2018-09-18 18:59:15 +03:00
committed by GitHub
parent 85965eb484
commit 5f34a5871f
10 changed files with 277 additions and 15 deletions

View File

@@ -1,15 +0,0 @@
package org.nativescript.widgets;
import android.view.MotionEvent;
import android.view.View;
/**
* Created by hhristov on 2/22/17.
*/
public final class DisableUserInteractionListener extends Object implements View.OnTouchListener {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return true;
}
}

View File

@@ -6,6 +6,7 @@ package org.nativescript.widgets;
import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
@@ -20,6 +21,11 @@ public abstract class LayoutBase extends ViewGroup {
super(context);
}
private boolean passThroughParent;
public boolean getPassThroughParent() { return this.passThroughParent; }
public void setPassThroughParent(boolean value) { this.passThroughParent = value; }
@Override
protected LayoutParams generateDefaultLayoutParams() {
return new CommonLayoutParams();
@@ -59,6 +65,18 @@ public abstract class LayoutBase extends ViewGroup {
public boolean shouldDelayChildPressedState() {
return false;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!this.passThroughParent) {
return super.onTouchEvent(event);
}
// LayoutBase.onTouchEvent(ev) execution means no interactive child view handled
// the event so we let the event pass through to parent view of the layout container
// because passThroughParent is set to true
return false;
}
protected static int getGravity(View view) {
int gravity = -1;