I would like to animate the appearance of a menu from a ToolStrip by mousing over a ToolStripMenuButton. When the user mouses over the ToolStripMenuButton, the menu should slide in by animation, and when the user moves the mouse off the ToolStripMenuButton or the resulting menu, the menu should then slide out by animation.
I've built code that I think should do this, but when the user moves the mouse cursor over the ToolStripMenuButton, the menu animates from 0, 0 (top left) instead of under the ToolStripMenuButton. Mouse out events never fire, so the menu doesn't hide as desired.
If you click on the ToolStripMenuButton, the menu appears where it should, under the ToolStripMenuButton. Subsequent mouse overs then cause the animated menu slide in to occur under the ToolStripMenuButton. Mouse out events still don't fire.
Here is a simple test case that reproduces the behavior.
I'm running SmartGWT Pro 2.5 from the nightly build of January 25th, 2011, on Firefox 3.6.13 on Ubuntu 10.04.
TIA for your help and advice.
I've built code that I think should do this, but when the user moves the mouse cursor over the ToolStripMenuButton, the menu animates from 0, 0 (top left) instead of under the ToolStripMenuButton. Mouse out events never fire, so the menu doesn't hide as desired.
If you click on the ToolStripMenuButton, the menu appears where it should, under the ToolStripMenuButton. Subsequent mouse overs then cause the animated menu slide in to occur under the ToolStripMenuButton. Mouse out events still don't fire.
Here is a simple test case that reproduces the behavior.
Code:
package com.smartgwt.sample.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.core.KeyIdentifier; import com.smartgwt.client.types.AnimationEffect; import com.smartgwt.client.util.KeyCallback; import com.smartgwt.client.util.Page; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.events.MouseOutEvent; import com.smartgwt.client.widgets.events.MouseOutHandler; import com.smartgwt.client.widgets.events.MouseOverEvent; import com.smartgwt.client.widgets.events.MouseOverHandler; import com.smartgwt.client.widgets.layout.VStack; import com.smartgwt.client.widgets.menu.Menu; import com.smartgwt.client.widgets.menu.MenuItem; import com.smartgwt.client.widgets.toolbar.ToolStrip; import com.smartgwt.client.widgets.toolbar.ToolStripMenuButton; /** * Entry point classes define <code>onModuleLoad()</code>. */ public class CustomDS implements EntryPoint { /** * This is the entry point method. */ public void onModuleLoad() { KeyIdentifier debugKey = new KeyIdentifier(); debugKey.setCtrlKey( true ); debugKey.setKeyName( "D" ); Page.registerKey( debugKey, new KeyCallback() { public void execute(String keyName) { SC.showConsole(); } } ); VStack vStack = new VStack(); vStack.setLeft( 175 ); vStack.setTop( 75 ); vStack.setWidth( "70%" ); vStack.setMembersMargin( 20 ); Label label = new Label(); label.setContents( "<ul>" + "<li>On first mouse over of Menu Button, menu animates at 0, 0 (top left) instead of " +"under the Menu Button.</li><li>If the menu is activated by mouse clicking, the menu appears correctly under the menu" + " Button. Subsequent mouse overs then cause the animated menu to appear under the Menu button.</li>" +"<li>Note that mouse out events do not fire as expected.</li>" + "</ul>" ); vStack.addMember( label ); ToolStrip toolstrip = new ToolStrip();; final Menu menu = new Menu(); menu.setShowShadow( true ); menu.setShadowDepth( 3 ); MenuItem menu1 = new MenuItem( "menu 1"); MenuItem menu2 = new MenuItem( "menu2" ); menu.setItems( menu1, menu2 ); ToolStripMenuButton menuButton = new ToolStripMenuButton( "Menu Button", menu ); menuButton.setWidth( 200 ); menuButton.setMenuAnimationEffect( "slide" ); menuButton.addMouseOverHandler( new MouseOverHandler() { @Override public void onMouseOver(MouseOverEvent event) { System.out.println("Mouse over settings button"); menu.animateShow( AnimationEffect.SLIDE ); } }); menuButton.addMouseOutHandler( new MouseOutHandler() { @Override public void onMouseOut(MouseOutEvent event) { System.out.println("No longer hovering over settings button."); menu.animateHide( AnimationEffect.SLIDE ); } }); toolstrip.addMenuButton( menuButton ); vStack.setMembers( label, toolstrip ); vStack.draw(); } }
TIA for your help and advice.
Comment