-
22 Oct 2012 6:32 AM #1
How to hide context menu of a button on mouseout event on menu
How to hide context menu of a button on mouseout event on menu
I am trying to use following code to hide the menu associated to a button. I am not sure how to bind it to the menu component. Will appreciate if anybody can help me out.
Ext.create('Ext.Button', {
text : 'Menu button',
renderTo : Ext.getBody(),
arrowAlign: 'right',
menu : [
{text: 'Item 1'},
{text: 'Item 2'},
{text: 'Item 3'},
{text: 'Item 4'}
],
listeners: {
mouseout: {
element: 'el',//Which element to use here if i want to bind mouseout to button's menu
fn: function(){ alert('on mouse out'); } // How to hide menu here
}
}
});
-
25 Oct 2012 6:40 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
You would need to put the mouseout on the menu correct?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
25 Oct 2012 9:46 PM #3
And it would need to be "mouseleave" because mouseout events bubble up from all levels.
Code:Ext.create('Ext.Button', { text : 'Menu button', renderTo : Ext.getBody(), arrowAlign: 'right', menu : { items: [ {text: 'Item 1'}, {text: 'Item 2'}, {text: 'Item 3'}, {text: 'Item 4'} ], listeners: { mouseleave: { element: 'el', fn: function(){ this.hide(); // The owning Component is the default scope } } } } });Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642


Reply With Quote