MCPcopy Create free account
hub / github.com/axmolengine/axmol / interceptTouchEvent

Method interceptTouchEvent

core/ui/UIScrollView.cpp:1128–1188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1126}
1127
1128void ScrollView::interceptTouchEvent(Widget::TouchEventType event, Widget* sender, Touch* touch)
1129{
1130 if (!_touchEnabled)
1131 {
1132 Layout::interceptTouchEvent(event, sender, touch);
1133 return;
1134 }
1135 if (_direction == Direction::NONE)
1136 return;
1137 Vec2 touchPoint = touch->getLocation();
1138 switch (event)
1139 {
1140 case TouchEventType::BEGAN:
1141 {
1142 _isInterceptTouch = true;
1143 _touchBeganPosition = touch->getLocation();
1144 handlePressLogic(touch);
1145 }
1146 break;
1147 case TouchEventType::MOVED:
1148 {
1149 _touchMovePosition = touch->getLocation();
1150 // calculates move offset in points
1151 float offsetInInch = 0;
1152 switch (_direction)
1153 {
1154 case Direction::HORIZONTAL:
1155 offsetInInch =
1156 convertDistanceFromPointToInch(Vec2(std::abs(sender->getTouchBeganPosition().x - touchPoint.x), 0.0f));
1157 break;
1158 case Direction::VERTICAL:
1159 offsetInInch =
1160 convertDistanceFromPointToInch(Vec2(0.0f, std::abs(sender->getTouchBeganPosition().y - touchPoint.y)));
1161 break;
1162 case Direction::BOTH:
1163 offsetInInch = convertDistanceFromPointToInch(sender->getTouchBeganPosition() - touchPoint);
1164 break;
1165 default:
1166 break;
1167 }
1168 if (offsetInInch > _childFocusCancelOffsetInInch)
1169 {
1170 sender->setHighlighted(false);
1171 handleMoveLogic(touch);
1172 }
1173 }
1174 break;
1175
1176 case TouchEventType::CANCELED:
1177 case TouchEventType::ENDED:
1178 {
1179 _touchEndPosition = touch->getLocation();
1180 handleReleaseLogic(touch);
1181 if (sender->isSwallowTouches())
1182 {
1183 _isInterceptTouch = false;
1184 }
1185 }

Callers

nothing calls this directly

Calls 6

Vec2Function · 0.50
absFunction · 0.50
getLocationMethod · 0.45
setHighlightedMethod · 0.45
isSwallowTouchesMethod · 0.45

Tested by

no test coverage detected