PDA

View Full Version : [DONE] Menu to offer a defaultOffsets config



Animal
17 Jun 2009, 11:37 PM
Sometimes you don't want a menu to align exactly flush with the sides of the element you are aligning to.

You can configure where, relative to another element you want your Menu to be popped up, (The defaultAlign config), but you cannot specify to then offset it a little (Only by an aftershow listener and budging it a bit)

It woould be easy to add a defaultOffsets config, so you'd get



/**
* @cfg {Array} defaultOffsets An array specifying the [x, y] offset in pixels by which to
* change the default Menu popup position after aligning according to the {@link #defaultAlign}
* configuration. Defaults to <code>[0, 0]</code>.
*/
defaultOffsets : [0, 0],

...

show : function(el, pos, parentMenu){
if(this.floating){
this.parentMenu = parentMenu;
if(!this.el){
this.render();
this.doLayout(false, true);
}
this.fireEvent("beforeshow", this);
this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign, this.defaultOffsets), parentMenu, false);
}else{
Ext.menu.Menu.superclass.show.call(this);
}
}

evant
23 Jun 2009, 11:26 PM
Simple one! Done.