Fix touch inspector when using Nodes
Reviewed By: astreet Differential Revision: D3433927 fbshipit-source-id: 5b17a16191f167db8f4491da37a1735e725e99b8
This commit is contained in:
parent
9803f3b0dc
commit
f236667a17
|
@ -77,7 +77,8 @@ public class JSTouchDispatcher {
|
||||||
ev.getX(),
|
ev.getX(),
|
||||||
ev.getY(),
|
ev.getY(),
|
||||||
mRootViewGroup,
|
mRootViewGroup,
|
||||||
mTargetCoordinates);
|
mTargetCoordinates,
|
||||||
|
null);
|
||||||
eventDispatcher.dispatchEvent(
|
eventDispatcher.dispatchEvent(
|
||||||
TouchEvent.obtain(
|
TouchEvent.obtain(
|
||||||
mTargetTag,
|
mTargetTag,
|
||||||
|
|
|
@ -46,7 +46,27 @@ public class TouchTargetHelper {
|
||||||
float eventX,
|
float eventX,
|
||||||
float eventY,
|
float eventY,
|
||||||
ViewGroup viewGroup) {
|
ViewGroup viewGroup) {
|
||||||
return findTargetTagAndCoordinatesForTouch(eventX, eventY, viewGroup, mEventCoords);
|
return findTargetTagAndCoordinatesForTouch(
|
||||||
|
eventX, eventY, viewGroup, mEventCoords, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find touch event target view within the provided container given the coordinates provided
|
||||||
|
* via {@link MotionEvent}.
|
||||||
|
*
|
||||||
|
* @param eventX the X screen coordinate of the touch location
|
||||||
|
* @param eventY the Y screen coordinate of the touch location
|
||||||
|
* @param viewGroup the container view to traverse
|
||||||
|
* @param nativeViewId the native react view containing this touch target
|
||||||
|
* @return the react tag ID of the child view that should handle the event
|
||||||
|
*/
|
||||||
|
public static int findTargetTagForTouch(
|
||||||
|
float eventX,
|
||||||
|
float eventY,
|
||||||
|
ViewGroup viewGroup,
|
||||||
|
@Nullable int[] nativeViewId) {
|
||||||
|
return findTargetTagAndCoordinatesForTouch(
|
||||||
|
eventX, eventY, viewGroup, mEventCoords, nativeViewId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,13 +77,15 @@ public class TouchTargetHelper {
|
||||||
* @param eventY the Y screen coordinate of the touch location
|
* @param eventY the Y screen coordinate of the touch location
|
||||||
* @param viewGroup the container view to traverse
|
* @param viewGroup the container view to traverse
|
||||||
* @param viewCoords an out parameter that will return the X,Y value in the target view
|
* @param viewCoords an out parameter that will return the X,Y value in the target view
|
||||||
|
* @param nativeViewTag an out parameter that will return the native view id
|
||||||
* @return the react tag ID of the child view that should handle the event
|
* @return the react tag ID of the child view that should handle the event
|
||||||
*/
|
*/
|
||||||
public static int findTargetTagAndCoordinatesForTouch(
|
public static int findTargetTagAndCoordinatesForTouch(
|
||||||
float eventX,
|
float eventX,
|
||||||
float eventY,
|
float eventY,
|
||||||
ViewGroup viewGroup,
|
ViewGroup viewGroup,
|
||||||
float[] viewCoords) {
|
float[] viewCoords,
|
||||||
|
@Nullable int[] nativeViewTag) {
|
||||||
UiThreadUtil.assertOnUiThread();
|
UiThreadUtil.assertOnUiThread();
|
||||||
int targetTag = viewGroup.getId();
|
int targetTag = viewGroup.getId();
|
||||||
// Store eventCoords in array so that they are modified to be relative to the targetView found.
|
// Store eventCoords in array so that they are modified to be relative to the targetView found.
|
||||||
|
@ -73,6 +95,9 @@ public class TouchTargetHelper {
|
||||||
if (nativeTargetView != null) {
|
if (nativeTargetView != null) {
|
||||||
View reactTargetView = findClosestReactAncestor(nativeTargetView);
|
View reactTargetView = findClosestReactAncestor(nativeTargetView);
|
||||||
if (reactTargetView != null) {
|
if (reactTargetView != null) {
|
||||||
|
if (nativeViewTag != null) {
|
||||||
|
nativeViewTag[0] = reactTargetView.getId();
|
||||||
|
}
|
||||||
targetTag = getTouchTargetForView(reactTargetView, viewCoords[0], viewCoords[1]);
|
targetTag = getTouchTargetForView(reactTargetView, viewCoords[0], viewCoords[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue