christocracy
25 Oct 2007, 8:56 AM
would it be ok to make a slight change in the order of event-firing in Ext.Button::onClick.
I'd like the Button's 'click' handler fired before menuShow() fires.
I'm attaching forms to an Ext.Menu and I'm using the button's click event to show/hide certain fieldsets.
before:
// private
onClick : function(e){
if(e){
e.preventDefault();
}
if(e.button != 0){
return;
}
if(!this.disabled){
if(this.enableToggle && (this.allowDepress !== false || !this.pressed)){
this.toggle();
}
if(this.menu && !this.menu.isVisible() && !this.ignoreNextClick){
this.showMenu();
}
this.fireEvent("click", this, e);
if(this.handler){
this.el.removeClass("x-btn-over");
this.handler.call(this.scope || this, this, e);
}
}
},
proposed
/***
* onClick
* override Ext.Button::onClick,
* @param {Object} e
*/
onClick : function(e){
if(e){
e.preventDefault();
}
if(e.button != 0){
return;
}
if(!this.disabled){
this.fireEvent("click", this, e); // <-- fire click-event first, before showMenu
if(this.enableToggle && (this.allowDepress !== false || !this.pressed)){
this.toggle();
}
if(this.menu && !this.menu.isVisible() && !this.ignoreNextClick){
this.showMenu();
}
// <-- click-event used to be fired here.
if(this.handler){
this.el.removeClass("x-btn-over");
this.handler.call(this.scope || this, this, e);
}
}
}
I'd like the Button's 'click' handler fired before menuShow() fires.
I'm attaching forms to an Ext.Menu and I'm using the button's click event to show/hide certain fieldsets.
before:
// private
onClick : function(e){
if(e){
e.preventDefault();
}
if(e.button != 0){
return;
}
if(!this.disabled){
if(this.enableToggle && (this.allowDepress !== false || !this.pressed)){
this.toggle();
}
if(this.menu && !this.menu.isVisible() && !this.ignoreNextClick){
this.showMenu();
}
this.fireEvent("click", this, e);
if(this.handler){
this.el.removeClass("x-btn-over");
this.handler.call(this.scope || this, this, e);
}
}
},
proposed
/***
* onClick
* override Ext.Button::onClick,
* @param {Object} e
*/
onClick : function(e){
if(e){
e.preventDefault();
}
if(e.button != 0){
return;
}
if(!this.disabled){
this.fireEvent("click", this, e); // <-- fire click-event first, before showMenu
if(this.enableToggle && (this.allowDepress !== false || !this.pressed)){
this.toggle();
}
if(this.menu && !this.menu.isVisible() && !this.ignoreNextClick){
this.showMenu();
}
// <-- click-event used to be fired here.
if(this.handler){
this.el.removeClass("x-btn-over");
this.handler.call(this.scope || this, this, e);
}
}
}