dontbugme
15 Oct 2010, 10:06 AM
I am having difficulties understanding how events work in Sencha Touch (and ExtJS on this matter).
For example I have 2 panels, a parent and a child one, and I want to trace some data when user touches (or mouse downs) the sub-panel. Any advice what am I missing?
Ext.setup({
icon:"icon.png",
glossOnIcon:true,
onReady:function() {
var sub1 = new Ext.Panel({
id:"sub1",
style: {
"background-color":"#FF00FF",
"border":"solid"
},
width:200,
height:200,
listeners: {
touchdown:function(event) {
console.info("touchdown", event);
},
"touchend":function(event) {
console.info("touchend", event);
},
"mousedown":function(event) {
console.info("mousedown", event);
}
},
html:"sub1 panel"
});
// Adding 2 soft and 1 browser events
sub1.addEvents("touchstart", "touchend", "mousedown");
var extended = new test.ExtendedPanel({
id:"extended",
style: {
"background-color":"#00FF00",
"border":"solid"
},
fullscreen:true,
html:"Extended Panel",
layout: {
type:"vbox"
}
});
extended.addSubPanel(sub1);
}
});
Ext.ns("test");
test.ExtendedPanel = Ext.extend(Ext.Panel, {
constructor:function(config) {
config = config || {};
// Array of sub panels
this.panels = [];
this.supr().constructor.call(this, config);
},
// Adds a panel to the end of panels
addSubPanel:function(panel) {
this.panels.push(panel);
this.add(panel);
this.doLayout();
},
// Removes last panel
removePanel:function() {
this.remove(this.panels[this.panels.length - 1]);
this.panels.pop();
this.doLayout();
}
});
For example I have 2 panels, a parent and a child one, and I want to trace some data when user touches (or mouse downs) the sub-panel. Any advice what am I missing?
Ext.setup({
icon:"icon.png",
glossOnIcon:true,
onReady:function() {
var sub1 = new Ext.Panel({
id:"sub1",
style: {
"background-color":"#FF00FF",
"border":"solid"
},
width:200,
height:200,
listeners: {
touchdown:function(event) {
console.info("touchdown", event);
},
"touchend":function(event) {
console.info("touchend", event);
},
"mousedown":function(event) {
console.info("mousedown", event);
}
},
html:"sub1 panel"
});
// Adding 2 soft and 1 browser events
sub1.addEvents("touchstart", "touchend", "mousedown");
var extended = new test.ExtendedPanel({
id:"extended",
style: {
"background-color":"#00FF00",
"border":"solid"
},
fullscreen:true,
html:"Extended Panel",
layout: {
type:"vbox"
}
});
extended.addSubPanel(sub1);
}
});
Ext.ns("test");
test.ExtendedPanel = Ext.extend(Ext.Panel, {
constructor:function(config) {
config = config || {};
// Array of sub panels
this.panels = [];
this.supr().constructor.call(this, config);
},
// Adds a panel to the end of panels
addSubPanel:function(panel) {
this.panels.push(panel);
this.add(panel);
this.doLayout();
},
// Removes last panel
removePanel:function() {
this.remove(this.panels[this.panels.length - 1]);
this.panels.pop();
this.doLayout();
}
});