zoukankan      html  css  js  c++  java
  • cocostudio的bug(1)

    今天有个女同事问我一个问题,两个cocostudio的ui同时addChild到一个layer上面,高层级的ui设置visible为false,低层级的ui设置的visible设置为true,然后低层级的ui上的点击事件不可点击,

    我记得UIButton类中的触摸事件是调用UIWidget中的onTouchBegan方法,下面是点击事件的处理过程:

    bool Widget::onTouchBegan(Touch *touch, Event *unusedEvent)
    {
        _hitted = false;
        if (isVisible() && isEnabled() && isAncestorsEnabled() && isAncestorsVisible(this) )
        {
            _touchBeganPosition = touch->getLocation();
            if(hitTest(_touchBeganPosition) && isClippingParentContainsPoint(_touchBeganPosition))
            {
                _hitted = true;
            }
        }
        if (!_hitted)
        {
            return false;
        }
        setHighlighted(true);
       
        /*
         * Propagate touch events to its parents
         */
        if (_propagateTouchEvents)
        {
            this->propagateTouchEvent(TouchEventType::BEGAN, this, touch);
        }
     
        pushDownEvent();
        return true;
    }

    如果visible为false的话,触摸事件不能触发,但是子节点的visible变量不为false,所以,子节点的触摸事件还是可以触发的,因此遮挡了低层次ui的触摸事件。这个是cocostudio源码开发者没有想得太周到的问题。

    转载请注明出处,from 博客园HemJohn

  • 相关阅读:
    ubuntu查看系统负载和程序运行状况
    ubuntu 离线装包
    python如何离线装包 离线如何部署python环境
    开发板上如何配置apahe2+mysql+php7
    c++指针实例
    nginx反向代理nginx,RealServer日志打印真实ip
    lvs+keep搭建高可用web服务
    linux一键安装vncserver脚本
    ansible 学习与实践
    centos7编译安装MySQL5.7.9
  • 原文地址:https://www.cnblogs.com/HemJohn/p/5656306.html
Copyright © 2011-2022 走看看