| 90 | } |
| 91 | |
| 92 | static 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 | |
| 109 | Node* Menu::itemForTouch(Touch* touch) { |
| 110 | Vec2 worldLocation = this->convertToWorldSpace(touch->getLocation()); |
no test coverage detected