I did write a small executeable program for represent my problem.
When I click and hold my mouse on one panel and pull to the other panel, the event from the start element is the only one that throw events. But what I like to get is the mouseover-event from the element which I pass, when its happened. Whether I’m not anymore on the pressed panel or not don’t change the current mouseover-element.
import com.jme3.app.SimpleApplication;
import com.jme3.niftygui.NiftyJmeDisplay;
public class Test extends SimpleApplication
{
private NiftyJmeDisplay niftyDisplay;
@Override
public void simpleInitApp()
{
getFlyByCamera().setEnabled(false);
niftyDisplay = new NiftyJmeDisplay(getAssetManager(), getInputManager(), getAudioRenderer(), getGuiViewPort());
niftyDisplay.getNifty().fromXml("StartScreenGUI.xml", "start");
getGuiViewPort().addProcessor(niftyDisplay);
}
public static void main(String[] args)
{
Test test = new Test();
test.start();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<nifty>
<screen id="start" controller="de.boldt.exo.client.StartController">
<layer id="layer" childLayout="center">
<panel id="base" width="100%" height="100%" imageMode="normal" childLayout="absolute-inside" />
</layer>
</screen>
</nifty>
public class StartController implements ScreenController
{
@Override
public void bind(Nifty nifty, Screen screen)
{
Element element = screen.findElementByName("base");
PanelBuilder panelBuilder1 = new PanelBuilder("panel1");
panelBuilder1.backgroundColor("#ff0000");
panelBuilder1.x("0%");
panelBuilder1.y("0%");
panelBuilder1.width("50%");
panelBuilder1.height("100%");
panelBuilder1.interactOnMouseOver("over(panel1)");
panelBuilder1.interactOnRelease("release(panel1)");
panelBuilder1.interactOnClickMouseMove("move(panel1)");
panelBuilder1.build(nifty, screen, element);
PanelBuilder panelBuilder2 = new PanelBuilder("panel2");
panelBuilder2.backgroundColor("#0000ff");
panelBuilder2.x("50%");
panelBuilder2.y("0%");
panelBuilder2.width("50%");
panelBuilder2.height("100%");
panelBuilder2.interactOnMouseOver("over(panel2)");
panelBuilder2.interactOnRelease("release(panel2)");
panelBuilder2.interactOnClickMouseMove("move(panel2)");
panelBuilder2.build(nifty, screen, element);
}
public void move(String id)
{
System.out.println("Move Id: " + id);
}
public void over(String id)
{
System.out.println("Over Id: " + id);
}
public void release(String id)
{
System.out.println("Release Id: " + id);
}
@Override
public void onStartScreen()
{
}
@Override
public void onEndScreen()
{
}
}
Btw. The same applies to released-event.
Press Panel1 → Released in Panel2
throw me:
Panel1 Pressed → Panel 1 released.
In the end I would have a real nice multi-functional drag&drop inventory. But no, the wrong element throw that the mouse is over him… Need help