PDA

View Full Version : Get the parent object of Ext.draw.Sprite



arvindwill
12 Dec 2012, 12:12 PM
How to get the parent (Ext.draw.Component) for a sprite which referenced was recived from the mouse event.

It dont have up() method, as it is not component. And it is useless to use the element's up method .
element.el.up('draw')
Any other way to find the Ext.draw.Component for a sprite from its reference.

mitchellsimoens
14 Dec 2012, 6:32 AM
The up method on an element is not going to resolve a component, it's going to try and resolve elements.

arvindwill
14 Dec 2012, 7:50 AM
Sorry, can you explicitly tell how to retrieve the component from sprite object?

Thanks

slemmon
14 Dec 2012, 9:22 AM
Try this. If you change the draw component's baseCls then '.x-surface' won't work - you'd need to use whatever you changed the baseCls to, but if you don't change it this should get you the draw component for the clicked (or whatever mouse event) sprite.



var drawComponent = Ext.create('Ext.draw.Component', {
viewBox: false,
items: [{
type: 'circle',
fill: '#79BB3F',
radius: 100,
x: 100,
y: 100
, listeners: {
click: function (sprite, e) {
console.log(Ext.getCmp(sprite.el.up('.x-surface').id));
}
}
}]
});