Ext.util.Observable:为EXT组件提供处理的最基本功能。
Ext.EventObject:Ext.EventObject包装了浏览器原生的事件对象,格式化了不同 浏览器之间的差异
Ext.EventManager:注册事件处理函数,它们 想要接受一个规格化的EventObject,而不是标准的浏览器事件, 并且直接提供一些有用的事件。例如:鼠标功能按键、onDocumentReady(可以用快捷方式Ext.onReady()进行访问。)
Employee = Ext.extend(Ext.util.Observable, {
constructor : function(config) {
this.name = config.name;
this.addEvents({
"fired" : true,
"quit" : true
});
// 拷贝配置的监听器到*this*对象里,使得基础类的
// 构造器将会被添加。
this.listeners = config.listeners;
// 调用我们父类的构造器来完成构造过程。
Employee.superclass.constructor.call(this, config)
}
});
Ext.onReady(function() {
/*
var newEmployee = new Employee({
// name : 'tom',
// listeners : {
// quit : function() {
// // 使用 default, 则"this"将会是触发事件的对象。
// alert(this.name + " has quit!");
// }
// }
name : 'tom'
});
newEmployee.on('quit', function() {
Ext.Msg.alert(this.name + " has quit!");
});
Ext.get('emp').on('click', function() {
newEmployee.fireEvent('quit');
});
*/
Ext.get('emp').on('keypress',function(e){
if(e.charCode==Ext.EventObject.SPACE){
Ext.Msg.alert("info","你点击了空格键")
}
})
});