bool Node::treeTouchesBegan( ci::app::TouchEvent event ) { if(!mIsVisible) return false; // test children first, from top to bottom NodeList nodes(mChildren); NodeList::reverse_iterator itr; bool handled = false; for(itr=nodes.rbegin(); itr!=nodes.rend()&&!handled; ++itr) handled = (*itr)->treeTouchesBegan(event); // if not handled, test this node if(!handled) handled = touchesBegan(event); return handled; }
bool TreentNode::deepTouchesBegan( ci::app::TouchEvent &event ) { bool captured = false; auto gui_component = component<GuiComponent>(); if( gui_component ) captured = gui_component->touchesBegan( event, getWorldTransform() ); for( TreentNodeRef &child : mChildren ) { // stop evaluation if event was captured by self or a child if( captured ) break; captured = child->deepTouchesBegan( event ); } return captured; }
void CCTouchDispatcher::OnPointerOn(const InputPointerEvent* evt) { CCSet set; CCTouch* pTouch = new CCTouch(); pTouch->SetTouchInfo(0, evt->getPos().x, evt->getPos().y); set.addObject(pTouch); m_Touches.insert(std::make_pair(evt->getSource(), pTouch)); pTouch->retain(); // LOG(0, ".. on %.3f %.3f\n", evt->GetPos().x, evt->GetPos().y); touchesBegan(&set); }
void CoreInput::setMouseButtonState(int mouseButton, bool state, int ticks) { InputEvent *evt = new InputEvent(mousePosition, ticks); evt->mouseButton = mouseButton; if(state) dispatchEvent(evt, InputEvent::EVENT_MOUSEDOWN); else dispatchEvent(evt, InputEvent::EVENT_MOUSEUP); mouseButtons[mouseButton] = state; if(simulateTouchWithMouse && mouseButton == MOUSE_BUTTON1) { TouchInfo touch; touch.position = mousePosition; touch.id = 0; std::vector<TouchInfo> touches; touches.push_back(touch); if(state) { touchesBegan(touch, touches, ticks); } else { touchesEnded(touch, touches, ticks); } } }