PDA

View Full Version : How to control Ext.draw.Sprites



Chielus
16 Aug 2011, 11:38 PM
Hi all,

I extended Ext.draw.Sprite, and made a widget of it. Now I want a controller to control this widget, this fails however.

VIEW:



Ext.define('VP.view.fields.Field' ,{
extend: 'Ext.draw.Sprite',
alias: 'widget.field',

constructor: function() {
var parentConfig = {
id: 'field',
fill: '#FFFF00',
type: 'rect',
width: '100%',
height: '100%',
x: 0,
y: 0
};
this.callParent([parentConfig]);
}
});


CONTROLLER:



Ext.define('VP.controller.Fields', {
extend: 'Ext.app.Controller',

views: [
'fields.Field'
],

init: function() {
console.log('Initialized Field controller!');
var me = this;
me.control({
'field': { //trying to control the widget.field, this fails
//'viewport > draw[surface]': { //this controls the surface successfully
//'viewport > draw[surface] > field': { //fails
click: this.addObject
}
});
},

addObject : function(event,el){
console.log(el);
//console.log(drawComponent);
}
});


This is probably because Ext.draw.Sprite doesn't extend Ext.Component.
How can I control this custom sprite?

Thanks in advance,
Chielus

PS: I'm not sure if this has to be in Q&A or Discussion forum