0

在 Sencha Touch Charts 2 beta 发行版中,绘图指南示例代码有一个 Sprite 监听触摸启动的示例。给出的代码无法绘制任何精灵,因为它无法将画布插入 DOM。但是,这可以通过替换它来解决:

    //add the component to the panel
    Ext.create('Ext.chart.Panel', {
      fullscreen: true,
      title: 'Yellow Circle',
      items: drawComponent
    });

有了这个:

    //add the component to the panel
    Ext.create('Ext.chart.Panel', {
      fullscreen: true,
      title: 'Yellow Circle',
      chart: drawComponent
    });

现在,我真的很想让事件处理工作。示例代码继续:

// Add a circle sprite
var myCircle = drawComponent.surface.add({
    type: 'circle',
    x: 100,
    y: 100,
    radius: 100,
    fill: '#cc5'
});

// Now do stuff with the sprite, like changing its properties:
myCircle.setAttributes({
    fill: '#ccc'
}, true);

// Remember always to refresh the image
drawComponent.surface.renderFrame();

// or animate an attribute on the sprite
// no need to refresh the image when adding animations.
myCircle.fx.start({
    fill: '#555'
});

// Add a touch listener to the sprite
myCircle.addListener('touchstart', function() {
    alert('touchstarted!');
});

但最后的警报永远不会在触摸时发生。有任何想法吗?

drawComponent.addListener('touchstart'... 工作正常,但当然没有本地化到圆形精灵。

---经过更多调查---

我认为答案很简单,他还没有实现对精灵的事件处理。例如在 touch-charts/src/draw/engine/Canvas.js 我们在 Ext.draw.engine.Canvas 的定义中,

getSpriteForEvent: function(e) {
    return null; //TODO!!!
},

好的 - 是时候将问题从“如何?” 到“什么时候?”:

“Sencha Touch 什么时候支持 Sprite 事件处理?”

4

0 回答 0