Here small patch that adds 2 parameters (showmenudelay, hidemenudelay) to Ext.Button class
this allow automaticlly show and hide button's menu.
Code:
--- Button.js-orig 2007-03-13 07:04:00.000000000 +0600
+++ Button.js 2007-03-23 14:03:33.000000000 +0600
@@ -49,6 +49,17 @@
};
if(this.menu){
this.menu = Ext.menu.MenuMgr.get(this.menu);
+
+ if(this.hidemenudelay) {
+ this.hidemenutask = new Ext.util.DelayedTask(this.menu.hide, this.menu);
+ this.menu.on('mouseout', function() {
+ this.hidemenutask.delay(this.hidemenudelay)}, this);
+ this.menu.on('mouseover', function() {this.hidemenutask.cancel()}, this);
+ }
+ if(this.showmenudelay) {
+ this.showmenutask = new Ext.util.DelayedTask(
+ function() {this.menu.show(this.el, this.menuAlign)}, this);
+ }
}
if(renderTo){
this.render(renderTo);
@@ -307,13 +318,25 @@
if(!this.disabled){
this.el.addClass("x-btn-over");
this.fireEvent('mouseover', this, e);
+ if (this.hidemenutask) {
+ this.hidemenutask.cancel();
+ }
+ if (this.showmenutask) {
+ this.showmenutask.delay(this.showmenudelay);
+ }
}
},
onMouseOut : function(e){
if(!e.within(this.el, true)){
this.el.removeClass("x-btn-over");
this.fireEvent('mouseout', this, e);
- }
+ if (this.hidemenutask) {
+ this.hidemenutask.delay(this.hidemenudelay);
+ }
+ if (this.showmenutask) {
+ this.showmenutask.cancel();
+ }
+ }
},
onMouseDown : function(){
if(!this.disabled){
@@ -325,9 +348,15 @@
},
onMenuShow : function(e){
this.el.addClass("x-btn-menu-active");
+ if (this.showmenutask) {
+ this.showmenutask.cancel();
+ }
},
onMenuHide : function(e){
this.el.removeClass("x-btn-menu-active");
+ if (this.hidemenutask) {
+ this.hidemenutask.cancel();
+ }
}
});