PDA

View Full Version : Adding a button to a menu



danh2000
28 Aug 2009, 10:37 PM
I'm just playing with the ability to add components to a Menu in Ext 3.

When I add a button, it's handler gets executed when clicking to the right outside the button.

I've added a hack to test the target and prevent this (see the Hack comment) - is this expected or am I missing something really obvious?


new Ext.menu.Menu({
id : 'myMenu',
plain: true,
showSeparator:false,
enableScrolling : false,
ignoreParentClicks: true,
items :[
new Ext.form.TextField({
id : 'somefield'
}),
{
xtype: 'button',
text : 'Done!',
handler : function(b,e) {
//Hack!
if(!e.within(b.el)){
return;
}

alert('Button Click');
var m = Ext.getCmp('myMenu');
m.hide();
}
}

]
);

Thanks,

Dan

Condor
29 Aug 2009, 1:30 AM
This has already been fixed in SVN (menu should only fire a click event on a menuitem and not on all component).