Android: How to Detect if user touches and drags out of button region?

Android: How to Detect if user touches and drags out of button region?
0

Android: How to Detect if user touches and drags out of button region? in cocos2d-x with ui::button, thanks

Add event listener to the scene:

listener = EventListenerTouchAllAtOnce::create();
    listener->onTouchesBegan = [&](const std::vector<Touch*>& touches, Event *event) {
        //detect if button was touched
    };
    
    listener->onTouchesMoved = [&](const std::vector<Touch*>& touches, Event *event) {
        //drag button around the scene
    };
    
    listener->onTouchesEnded = [&](const std::vector<Touch* >& touches, Event *event) {
         //end dragging
    };

    listener->onTouchesCancelled = [&](const std::vector<Touch* >& touches, Event *event) {
         //end dragging
    };

this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);