mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user