PDA

View Full Version : Menu question? automatically drop down?



skyey
13 Jul 2007, 2:08 AM
How to:The menu automatically drop down when i put the cursor over it.

evant
13 Jul 2007, 2:38 AM
Assuming you want it to show up over some element, try:



Ext.get('someElement').on('mouseover', function(e)
{
menu.showAt(e.getXY());
}
);

para
13 Jul 2007, 5:34 AM
That should work if you're talking about a context menu. If you want each menu item in a toolbar to expand when it is moused over, try this...
You have to add a listener to each of the menu items. You can do this on creation of the items, or after they are already in the menu. This is for when the menubar (called 'menubar') is already created.


for(var a in menubar.items.items) {
if(a=='remove'){continue;}
var item = menubar.items.items[a];
item.on('mouseover', function(e) {
this.onClick();
}
);
}


Let me know if this helps.

Animal
13 Jul 2007, 6:34 AM
That's if you're trying to use an Ext.Toolbar as a menu bar. They're not the same thing.

Ext needs a menu bar. There is an extension class Menubar.

skyey
15 Jul 2007, 7:19 PM
to:para
i use an Ext.Toolbar.

evant code can do,but i want to show at the bottom of menu,not mouse xy

evant
15 Jul 2007, 8:27 PM
Ext.get('someElement').on('mouseover', function(e)
{
//el that was moused over
var el = Ext.get(e.getTarget());
menu.showAt(something);

}
);

skyey
15 Jul 2007, 11:06 PM
Ext.onReady(function(){

Ext.QuickTips.init();

var menu = new Ext.menu.Menu({
id: 'mainMenu',
items: [{
text:"aa Entry"
},
{
text: 'bb Entry'

},{
text: 'cc Entry'

}
]
});

var menubar = new Ext.Toolbar('toolbar');
menubar.add({
id: 'bar',
text:'top 1',
menu: menu // assign menu by instance
});

Ext.get('bar').on('mouseover', function(e){
//el that was moused over
var el = Ext.get(e.getTarget());
menu.show(el,'tr-br?');

}
);



});


to evant : can you help me...

evant
15 Jul 2007, 11:10 PM
What doesn't work?

Animal
15 Jul 2007, 11:14 PM
A Toolbar will not do. It is not a Menu, it does not know about any "submenus", so will not automaically show them. There is a menu bar extension in the user extensions folder. That is what you need.

kell
16 Jul 2007, 6:07 PM
Here is a link to a wiki page that gives a brief description of the extension. From this page, there is a link to a demo page where you can download the code.
http://extjs.com/learn/Extension:MenuBar

pooh
31 Oct 2007, 8:31 PM
Hi,

I too hav the same problem...
i tried using the menubar extension that you gave... But it drops down the submenu only when i click on the main menu. And it stays open until i select an item. I don want this functionality... I need it to be displayed when i hover on the menu...

Can you please help me in this regard...

Thanks in advance...

Pooh

gaspard
28 Jan 2008, 6:47 PM
hi, but i want to know how to make the sub-menu item stay here while i put the mouse on the menu item, as the sub-menu disppeared if i switch from the item to the sub-menu very quick