Пример #1
0
CX_METHOD_DEF(cxButton,OnTouch,cxBool,const cxTouchItems *points)
{
    CX_RETURN(points->number != 1,false);
    cxTouchItem item = points->items[0];
    if(!this->IsEnable){
        return false;
    }
    if(item->type == cxTouchTypeMove){
        return this->isSelected && !this->IsPass;
    }
    cxHitInfo hit = cxViewHitTest(this, item->position);
    if(item->type != cxTouchTypeDown && this->isSelected && !hit.hited){
        CX_CALL(this, OnTouchLeave, CX_M(void));
        this->isSelected = false;
        return false;
    }
Пример #2
0
cxBool cxButtonTouch(cxAny pview,cxTouch *touch)
{
    cxButton this = pview;
    if(!this->isEnable){
        return false;
    }
    cxBool hit = cxViewHitTest(pview, touch->current, NULL);
    if(!hit && this->isDown){
        CX_EVENT_FIRE(this, onLeave);
        this->isDown = false;
    }
    if(!hit){
        return false;
    }
    if(touch->type == cxTouchTypeDown){
        this->isDown = true;
        CX_EVENT_FIRE(this, onEnter);
        CX_EVENT_FIRE(this, onPress);
        return true;
    }
    if(!this->isDown){
        return false;
    }
    if(touch->type == cxTouchTypeMove && cxVec2fMagnitude(touch->movement) > this->movement){
        CX_EVENT_FIRE(this, onLeave);
        this->isDown = false;
        return false;
    }
    if(touch->type == cxTouchTypeUp){
        this->isDown = false;
        CX_EVENT_FIRE(this, onRelease);
        CX_EVENT_FIRE(this, onLeave);
        return true;
    }
    return false;
}