Click to focus in hierarchy

Summary:
as title; this shouldn't change how focus worked before on views, but accounts for the new Section nodes
Depends on D13900789

Reviewed By: astreet

Differential Revision: D13900846

fbshipit-source-id: 093016c17b5c1351108dbd9c884bf99a1b4d49cb
This commit is contained in:
Mihaela Ogrezeanu
2019-02-12 06:25:13 -08:00
committed by Facebook Github Bot
parent 8855687963
commit 73b816de16

View File

@@ -121,7 +121,38 @@ public class DebugSectionDescriptor extends NodeDescriptor<DebugSection> {
@Override
public void hitTest(DebugSection node, Touch touch) throws Exception {
// TODO T39526148
final int childCount = getChildCount(node);
// For a DiffSectionSpec, check if child view to see if the touch is in its bounds.
// For a GroupSectionSpec, check the bounds of the entire section.
if (node.isDiffSectionSpec()) {
for (int i = 0; i < childCount; i++) {
View child = (View) getChildAt(node, i);
int left = child.getLeft() + (int) child.getTranslationX();
int top = (child.getTop() + (int) child.getTranslationY());
int right = (child.getRight() + (int) child.getTranslationX());
int bottom = (child.getBottom() + (int) child.getTranslationY());
final boolean hit = touch.containedIn(left, top, right, bottom);
if (hit) {
touch.continueWithOffset(i, left, top);
return;
}
}
touch.finish();
} else {
for (int i = 0; i < childCount; i++) {
DebugSection child = (DebugSection) getChildAt(node, i);
Rect bounds = child.getBounds();
final boolean hit = touch.containedIn(bounds.left, bounds.top, bounds.right, bounds.bottom);
if (hit) {
touch.continueWithOffset(i, 0, 0);
return;
}
}
touch.finish();
}
}
@Override