Sencha Touch - Sprite Event Listeners

276 Views Asked by At

I have been trying to add a touch event listener to my app in Sencha touch 2.3.1, but the listener is not added.

This is my code overview :

var drawComponent = new Ext.draw.Component();


var myCircle1 = drawComponent.getSurface('main').add({
    id: 'circle1',
    type: 'circle',
    fill: '#79BB3F',
    radius: 100,
    cx: 100,
    cy: 100

});


myCircle1.addListener('tap',function(){
    alert('Touched');

});

Through the console, when I check for myCircle1.getListeners(), it returns null.

Basically I want to display a lot of sprites (circles and rectangles) with predefined positions and add an tap event so that I can display various information.

I can do them with just buttons as well. But is there way where I can position the buttons at various positions(x,y) instead of hbox or vbox layouts?

Any direction would be of great help. Cheers.

Vignesh

1

There are 1 best solutions below

2
Dinkheller On

Ext.draw.Component does not have a tap event.

http://docs.sencha.com/touch/2.3.1/#!/api/Ext.draw.Component

see the Events

I have not worked with Ext.draw.Component a lot, but it might be possible to cast the click event on the dom to the component.

drawComponent.element.dom.on('click', function() {drawComponent.fireEvent(tap, arguments);})

something like this.