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

  • 相关阅读:
    SQL Server 触发器
    [转]SQL Server 存储过程
    C#-DataView及其用法
    IEnumerable和IEnumerator 详解 And迭代器
    C#多线程学习(六) 互斥对象
    GDI简单的图片处理
    C#委托的介绍(delegate、Action、Func、predicate)
    接口的理解与使用《转》
    Mysql drop、delete和truncate的区别
    如何查看笔记本CPU是几核的?
  • 原文地址:https://www.cnblogs.com/HemJohn/p/5656306.html
Copyright © 2011-2022 走看看