1

我在使用 ExtJS4 及其绘图组件进行事件冒泡时遇到了一些困难:

drawComponent.on('click', function(){
    var sprite = Ext.create('Ext.draw.Sprite', {
        type: 'circle',
        fill: '#79BB3F',
        stroke: '#000000',
        'stroke-width': 1,
        radius: 100,
        x: 100,
        y: 100,
        surface: this.surface,
        listeners: {
            'click': function(el,e){
                console.log('clicked');
                e.stopPropagation();
            }
        }
    });
    sprite.show(true);
});

单击 时drawComponent,会绘制一个圆圈。单击圆圈时,这应该只触发clickHandler圆圈的 ,而不是drawComponent

知道我的代码有什么问题吗?e.stopPropagation()应该停止事件泡沫。

谢谢,基卢斯

4

1 回答 1

0

使用addManagedListeners方法而不是listeners属性来添加点击事件。

组件上的click事件也应该被删除。

参考

于 2014-10-08T23:41:14.407 回答