MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / getTouchedItem

Function getTouchedItem

Source/Node/Menu.cpp:92–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92static Node* getTouchedItem(Node* parentItem, const Vec2& worldLocation) {
93 Array* children = parentItem->getChildren();
94 if (children && !children->isEmpty()) {
95 for (int i = s_cast<int>(children->getCount()) - 1; i >= 0; i--) {
96 Node* childItem = children->get(i)->to<Node>();
97 if (childItem && childItem->isVisible() && childItem->isTouchEnabled()) {
98 Vec2 local = childItem->convertToNodeSpace(worldLocation);
99 if (Rect(Vec2::zero, childItem->getSize()).containsPoint(local)) {
100 Node* targetItem = getTouchedItem(childItem, worldLocation);
101 return targetItem ? targetItem : childItem;
102 }
103 }
104 }
105 }
106 return parentItem;
107}
108
109Node* Menu::itemForTouch(Touch* touch) {
110 Vec2 worldLocation = this->convertToWorldSpace(touch->getLocation());

Callers 1

itemForTouchMethod · 0.85

Calls 10

isTouchEnabledMethod · 0.80
convertToNodeSpaceMethod · 0.80
getMethod · 0.65
RectClass · 0.50
getChildrenMethod · 0.45
isEmptyMethod · 0.45
getCountMethod · 0.45
isVisibleMethod · 0.45
containsPointMethod · 0.45
getSizeMethod · 0.45

Tested by

no test coverage detected