Hello,
I have a menuButton with menu. Just like its done in browser, menuButton should be selected while a menu is opened.
To implement it, my MenuButton should know if menu is hidden, to change its state.
How menuButton can know if its menu is hidden? I tried overriding Menu.hide() function, from there I notify a menuButton "listener". However, hide() isn't invoked when user opens a menu, and then clicks outside it.
I use smartGWT 2.1, below is my code (it uses event listeners to select / unselect a menuButton):
thank you
I have a menuButton with menu. Just like its done in browser, menuButton should be selected while a menu is opened.
To implement it, my MenuButton should know if menu is hidden, to change its state.
How menuButton can know if its menu is hidden? I tried overriding Menu.hide() function, from there I notify a menuButton "listener". However, hide() isn't invoked when user opens a menu, and then clicks outside it.
I use smartGWT 2.1, below is my code (it uses event listeners to select / unselect a menuButton):
Code:
//add listeners to hide/show menu menu.addMouseOutHandler(new MouseOutHandler() { public void onMouseOut(MouseOutEvent event) { menuButton.setSelected(false); menu.hide(); } }); menu.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { menuButton.setSelected(false); } }); menuButton.addMouseDownHandler(new MouseDownHandler() { public void onMouseDown(MouseDownEvent event) { menuButton.setSelected(true); //unselect the rest menu.showNextTo(menuButton, "bottom"); } }); //menuImpl class - to override hide() public class MenuImpl extends Menu { private MenuButton eventHandler; public void setListener(MenuButton button){ eventHandler = button; } public void hide(){ super.hide(); eventHandler.setSelected(false); } }
thank you
Comment