//----------------------------------------------------------------------------- void CFrame::platformOnTouchEvent (ITouchEvent& event) { std::vector<CView*> targetDispatched; bool hasBeganTouch = false; for (const auto& e : event) { CView* target = e.second.target; if (target) { if (e.second.targetIsSingleTouch) { CButtonState buttons (kLButton); CPoint where (e.second.location); target->frameToLocal (where); switch (e.second.state) { case ITouchEvent::kMoved: { CMouseEventResult result = target->onMouseMoved (where, buttons); if (result == kMouseMoveEventHandledButDontNeedMoreEvents) { event.unsetTouchTarget(e.first, target); if (target->hitTest (where, buttons) == false) { // when the touch goes out of the target and it tells us to const_cast<ITouchEvent::Touch&> (e.second).state = ITouchEvent::kBegan; hasBeganTouch = true; } } break; } case ITouchEvent::kCanceled: { if (target->onMouseCancel () != kMouseEventHandled) target->onMouseUp (where, buttons); event.unsetTouchTarget (e.first, target); break; } case ITouchEvent::kEnded: { target->onMouseUp (where, buttons); event.unsetTouchTarget (e.first, target); break; } default: { // do nothing break; } } } else { if (std::find (targetDispatched.begin (), targetDispatched.end (), target) == targetDispatched.end ()) { target->onTouchEvent (event); targetDispatched.push_back (target); } } } else if (e.second.state == ITouchEvent::kBegan) { hasBeganTouch = true; } } if (hasBeganTouch) { if (CView* focusView = getFocusView ()) { if (dynamic_cast<CTextEdit*> (focusView)) setFocusView (0); } for (const auto& e : event) { if (e.second.target == 0 && e.second.state == ITouchEvent::kBegan) { findSingleTouchEventTarget (const_cast<ITouchEvent::Touch&> (e.second)); } } onTouchEvent (event); } }