Im having a problem with Nifty Menu where the mouseEvent is not consumed when using the left mouse button to select the menu item.
I have not found any reports of this problem anywhere on the forums so I assume its something I am doing to make this happen.
Has anyone else seen this behavior?
I have tried adding a custom control definition (hacked version of the default definition that uses the nifty default controllers ) edited to use “onPrimaryRelease” for the mouse and made the panels also “visibleToMouse” as a work around.
<?xml version="1.0" encoding="UTF-8"?>
<nifty-controls xmlns="http://nifty-gui.lessvoid.com/nifty-gui">
<!-- the menu control -->
<controlDefinition name="popupMenu" controller="de.lessvoid.nifty.controls.menu.MenuControl" >
<panel style="nifty-panel-bright" width="150px" childLayout="vertical" paddingLeft="0px" paddingRight="0px" visibleToMouse="true">
</panel>
</controlDefinition>
<!-- the menu item control -->
<controlDefinition name="popupMenuItem" controller="de.lessvoid.nifty.controls.MenuItemControl"
inputMapping="de.lessvoid.nifty.input.mapping.MenuInputMapping">
<panel style="niftyMenuItemStyle" visibleToMouse="true">
<interact onPrimaryRelease="$menuOnClick" onSecondaryRelease="$menuOnClick" onSecondaryClick="$menuOnClick"/>
<panel width="10px" height="23px"/>
<image id="#icon" visible="$menuIconVisible" width="23px" height="23px" filename="$menuIcon"/>
<panel width="5px" height="23px"/>
<control id="#text" style="#text" name="label" text="$menuText"/>
</panel>
</controlDefinition>
<!-- the menu item separator control -->
<controlDefinition name="popupMenuItemSeparator">
<panel style="niftyMenuItemSeparatorStyle">
<panel style="#line"/>
</panel>
</controlDefinition>
<!-- and the popup -->
<popup id="customPopupMenu" childLayout="absolute-inside"
controller="de.lessvoid.nifty.controls.menu.PopupMenuControl">
<interact onPrimaryRelease="closePopup()" onSecondaryClick="closePopup()" />
<control id="#popupmenu" name="popupMenu"/>
</popup>
</nifty-controls>
This definition loads with no errors and I use it in the menu creation code but all changes to the definition are ignored.
What am I doing wrong that allows this to be ignored?
private void createPopup() {
this.popup = nifty.createPopup("customPopupMenu");
popupMenu = popup.findNiftyControl("#popupmenu", Menu.class);
popupMenu.setWidth(new SizeValue("250px"));
popupMenu.addMenuItem("Lock/Unlock MiniMap Drag", new DragNDrop("minimap_drag"));
popupMenu.addMenuItemSeparator();
popupMenu.addMenuItem("Exit", new DragNDrop("exit"));
}