0

Sencha Touch Charts 2ベータ分布では、描画ガイドのサンプルコードに、タッチスタートをリッスンするスプライトの例があります。与えられたコードは、キャンバスを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!!!
},

OK-質問を「どのように?」から変更する時が来ました。「いつ?」へ:

「SenchaTouchはいつSpriteイベント処理をサポートしますか?」

4

0 に答える 0