Skip to content

Instantly share code, notes, and snippets.

@dmackerman
Created December 28, 2011 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmackerman/1528101 to your computer and use it in GitHub Desktop.
Save dmackerman/1528101 to your computer and use it in GitHub Desktop.
//Override
Ext.override(Ext.Button, {
preventFocus : false,
// @override
onMouseDown : function(e){
if(!this.disabled && e.button === 0){
if (this.preventFocus) { // injected line here
e.stopEvent();
}
this.getClickEl(e).addClass('x-btn-click');
this.doc.on('mouseup', this.onMouseUp, this);
}
},
// @override
onMouseUp : function(e){
if(e.button === 0){
if (this.preventFocus) { // injected line here
e.stopEvent();
}
this.getClickEl(e, true).removeClass('x-btn-click');
this.doc.un('mouseup', this.onMouseUp, this);
}
}
});
//Usage
new Ext.Button({
preventFocus : true,
text : 'I do not focus on click!'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment