Menu system – not closing

Hello

First of all thank you for your efforts in providing this nice gui. I am trying it for my application and have problems with nested menus:
The menu looks like this:

But after selection of an item, the menu does not close correctly:

Thanks for your comments and help.

Michael

1 Like

Hi Micheal,

Sorry for the delay. Life has been kicking my butt over the past 2 weeks. Death in the family, then an uber illness (lucky me).

Let me see what I can do about this. Can you do me a favor and post a simplified version of the code used to create the menus?

Hello,

I am sorry to hear that. This is always a sad situation. My deepest condolences

I will prepare a small case for testing (today or tomorrow). In my application, I hide the menu after 4 seconds when the mouse is not used. So, as a workaround, I could hide the remaining menus …

BTW: I created the first windows with your lib and can say that I like your library very much.
… and a feature request: It would be great, if the MenuItem has a method .setIsEnabled(boolean isEnabled). In the disabled case, the menu item should not be highlighted and the callback never called …

1 Like

Here is the small example. You see that when you leave the submenu and click into the screen, the menu does not close as one would expect.

Thanks for your help.

Michael
[java]
import tonegod.gui.controls.buttons.ButtonAdapter;
import tonegod.gui.controls.menuing.Menu;
import tonegod.gui.core.Screen;

import com.jme3.app.SimpleApplication;
import com.jme3.input.event.MouseButtonEvent;
import com.jme3.math.Vector2f;

public class TestNestedMenu extends SimpleApplication {
private ButtonAdapter menuButton;
private Menu menu;
private Menu subMenu;
private Screen screen;

public static void main(String[] args){
	TestNestedMenu app = new TestNestedMenu();
	app.start();
}

@Override
public void simpleInitApp() {
	flyCam.setDragToRotate(true);
	screen = new Screen(this);
	guiNode.addControl(screen);		
	menuButton = new ButtonAdapter(screen, "but001", new Vector2f(10,10)) {
		@Override
		public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean isToggled) {
			menu.showMenu(null, getAbsoluteX(), getAbsoluteY()-menu.getHeight());
		}
	};
	menuButton.setText("Click here");
	menu = new Menu(
			screen,
			"id1",
			new Vector2f(0,0),
			false
	) {
		@Override
		public void onMenuItemClicked(int index, Object value, boolean isToggled) {
		}
	};

	for (int i=0; i <5; i++) {
		menu.addMenuItem("Menu " + i, i, null, true);
	}
	subMenu = new Menu(
			screen,
			"id2",
			new Vector2f(0,0),
			false
	) {
		@Override
		public void onMenuItemClicked(int index, Object value, boolean isToggled) {
		}
	};
	for (int i=0; i <5; i++) {
		subMenu.addMenuItem("Sub-Menu " + i, i, null);
	}
	menu.addMenuItem("Menu sub", 99, subMenu);
	screen.addElement(menuButton);
	screen.addElement(menu);
}

}
[/java]