PDA

View Full Version : Alpha 1.0 - Menu with image (not toolbar)



thameema
23 Feb 2007, 2:37 AM
I am using Alpha 1.0 menu API to build the menu which is similar to yahoo menu YUI example, http://developer.yahoo.com/yui/examples/menu/topnavfrommarkupwithanim.html

I checked the example coming with the alpha package and it has only toolbar example. My requirement is the initial parent menu is an image and mouse over that image will render the child menu. Please help me achieve this.

Thanks,
Thameem

mnugter
23 Feb 2007, 3:21 AM
this should do it:


var menu = new Ext.menu.Menu({shadow: false});
menu.add(
{id:"opt1", text: 'option1'},
{id:"opt2", text: 'option2'}
);
Ext.get('test').on('mouseover', function() {
menu.show(Ext.get('test'), "tl-bl")
});


Having this image tag:


/path/to/image.gif

thameema
23 Feb 2007, 3:35 AM
Thanks for the suggestion. But I don't think this is the clear way to do it. Because when I mouse over the image it pops up the menu. But when I mouse out the menu stays there. If I add event handler for 'mouse out' its not even popping up the menu. And moreover the menu is appearing below the image. So, there might be a good way of doing this.

Jack, You can shed some light on this.

Thanks,
Thameem

mnugter
23 Feb 2007, 4:21 AM
The menu follows the windows-logic. When a menu is activated you can only deactivate it by clicking outside the menu.

The problem with the mouseout event is that you will trigger it as soon as you leave the image (and enter the menu).

jack.slocum
23 Feb 2007, 4:27 AM
The default logic as mnugter said is to hide on mousedown somewhere. If you need other logic it is definitely possible but you would have to add it. I can help, if you have questions.

Also, the second param 'tl-bl?' is an alignTo alignment option. Take a look at Ext.Element.alignTo which has great documentation on the format for these alignment options.