cocos creator BlockInputEvents 无法屏蔽穿透输入框问题

cocos creator 版本 2.1.1

今天遇到一个问题 使用 BlockInputEvents 的时候发现 该组件 无法屏蔽 cc.EditBox 输入框 输入事件。

先上图:

cocos creator BlockInputEvents 无法屏蔽穿透输入框问题

网站找也没有找到正确的解释:

这里发现其他按钮事件是可以屏蔽的。

原因应该是在鼠标经过的时候 输入框(editbox)触发了全局光标事件,鼠标移动到这里会变成输入模式。应该是这个原因导致 BlockInputEvents 组件,无法拦截这个输入状态事件,导致事件穿透。

这里可以迂回处理一下,

               this.input_off_on(false); //首先是将输入框的enabled关闭

                this.alert('发送失败,请重试!', function () {//然后弹窗,弹窗后点击按钮回调方法,恢复输入状态。

                    this.input_off_on(true);

                });

    input_off_on: function (bool) {

        cc.find('huangdi/shoujiinputimg/shoujiinput', this.node).getComponent(cc.EditBox).enabled = bool;

        cc.find('huangdi/yanzhengmainputimg/yanzhengmainput', this.node).getComponent(cc.EditBox).enabled = bool;

    },

完:cocos creator 绕坑记录