GuiNode – nifty and RootNode overlapping

Hello all,



When the user put the mouse over a brown square, the square is red enlightened. Everything work like a charm…

Recently a try to add some hud with the help of nifty.



When the user move the mouse over a nifty panel and if a brown square is “under” this panel. The square is enlightened…

http://i.imgur.com/ZhYgd.png



How can I “say” :

[java]

if (the mouse is over a nifty Panel) {

DISABLE PickingManager AppState

}

else {

ENABLE PickingManager AppState

}

[/java]



I don’t know if this is possible because my hud screen is composed of two panel :

http://i.imgur.com/bh8J4.png



Here is my nifty declaration made in a AppState - ScreenController :

[java]

NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, app.getAudioRenderer(), app.getGuiViewPort());

nifty = niftyDisplay.getNifty();

nifty.fromXml(“Interface/Nifty/gui.xml”, “hud”, this);

app.getGuiViewPort().addProcessor(niftyDisplay);

[/java]



I try with “GuiViewPort()” and “ViewPort()” with the same result.



Here is my PickingManager update loop that I want to disable :

[java]

// results list.

CollisionResults results = new CollisionResults();

// the ray from cam loc to mouse

Vector3f origin = app.getCamera().getWorldCoordinates(inputManager.getCursorPosition(), 0.0f);

Vector3f direction = app.getCamera().getWorldCoordinates(inputManager.getCursorPosition(), 0.3f);

direction.subtractLocal(origin).normalizeLocal();

Ray ray = new Ray(origin, direction);



if (results.size() > 0) {

CollisionResult closest = results.getClosestCollision();

stateManager.getState(GameManager.class).highlightHole(closest.getGeometry().getName());

}

[/java]



I realize I am not very clear, sorry.



Thanks.



Pierre

from

[java]if (the mouse is over a nifty Panel) {

DISABLE PickingManager AppState}

else {

ENABLE PickingManager AppState} [/java]



there are nifty event subscribers for mouse move events, so you should be able to check the id for 1 of your panels, there maybe on focus (I can’t remember)

1 Like

Thank you for the clue !!



I modify my nifty-gui.xml with interact onMouseOver







[xml]

<panel id="panel_bottom" width="100%" height="20%" childLayout="horizontal" >

<interact onMouseOver="disablePicking()"/>

<control name="button" label="Quit" id="QuitButton" align="right" valign="center"/>

<control name="button" label="Start" id="QuitButton" align="right" valign="center"/>

</panel>

[/xml]

And for the top panel :

[xml]<interact onMouseOver="enablePicking()"/>[/xml]

1 Like

it seems visibleToMouse=“true” attribute on the panel should normally consume the mouseEvent. You can still choose to transmit it if needed but nifty doesn’t transmit the event to the main application and treat the event if you attach something on it by default for all the elements with that attribute.

1 Like

So…



My solution with panel interaction :

[xml]<interact onMouseOver=“disablePicking() / enablePicking()”/>[/xml]

works well but all mouse clicks are disabled…



The solution with [xml]<panel id=“panel_bottom” … visibleToMouse=“true”> [/xml]

consume the mouse clicks but don’t consume the mouse moves.



In the “disablePicking() / enablePicking()” methods, here is the simple code :

[java]stateManager.getState(PickingManager.class).setEnabled(true / false);[/java]





How can merged the two solutions ?