Nifty Window not accepting input after clicking into the scene

Hello,



after fixing the bone.getAttachmentsNode() thing in my editor I noticed that another error occurs: When I click into the scene I can’t select anything in my nifty window anymore. How can I change that? I’ll post a (long) showCase:



[java]package editor;



import de.lessvoid.nifty.Nifty;

import de.lessvoid.nifty.NiftyEventSubscriber;

import de.lessvoid.nifty.builder.LayerBuilder;

import de.lessvoid.nifty.builder.PanelBuilder;

import de.lessvoid.nifty.builder.ScreenBuilder;

import de.lessvoid.nifty.controls.ButtonClickedEvent;

import de.lessvoid.nifty.controls.CheckBoxStateChangedEvent;

import de.lessvoid.nifty.controls.button.builder.ButtonBuilder;

import de.lessvoid.nifty.controls.checkbox.builder.CheckboxBuilder;

import de.lessvoid.nifty.controls.label.builder.LabelBuilder;

import de.lessvoid.nifty.controls.window.builder.WindowBuilder;

import de.lessvoid.nifty.screen.Screen;

import de.lessvoid.nifty.screen.ScreenController;



public class EditorScreenBuilder2 extends ScreenBuilder {



private ShowCase sc;

private BigController bc;



public EditorScreenBuilder2(ShowCase me) {

super(“start”);

this.sc = me;

bc = new BigController(sc);

buildGUI();

}



private void buildGUI() {

controller(bc);

layer(new LayerBuilder(“baseLayer”) {

{

childLayoutAbsolute();



control(new WindowBuilder(“myWindow”, “Title of Window”) {

{

visibleToMouse(true);

closeable(false); // you can close this window -.-



width(“200px”); // windows will need a size

height(“70%”);

y(“10%”);



backgroundColor("#0000FFFF");



panel(new PanelBuilder() {

{

childLayoutVertical();

//Mesh CheckBox

panel(new PanelBuilder() {

{

childLayoutHorizontal();

control(new LabelBuilder() {

{

text(“Show Meshes:”);

color("#eee");



}

});

control(new CheckboxBuilder(“showMeshes”) {

{

checked(true);

color("#eee");

}

});

}

});

//Spacer

panel(new PanelBuilder() {

{

height(“20px”);



}

});

//EditButton

panel(new PanelBuilder() {

{

childLayoutCenter();

control(new ButtonBuilder(“view”, “Edit”));

}

});



}

}); //End WindowPanel



}

}); //End WIndow



}

});

}



public static class BigController implements ScreenController {



private ShowCase sc;



public BigController(ShowCase sc) {

this.sc = sc;

}



@Override

public void bind(Nifty arg0, Screen arg1) {

}



@Override

public void onEndScreen() {

}



@Override

public void onStartScreen() {

}



@NiftyEventSubscriber(id = “showMeshes”)

public void meshesClicked(String id, CheckBoxStateChangedEvent event) {

System.out.println(“Nifty Input”);

}



@NiftyEventSubscriber(id = “view”)

public void viewChange(String id, ButtonClickedEvent event) {

System.out.println(“Nifty Input”);

}

}

}

[/java]



[java]import java.util.logging.ConsoleHandler;

import java.util.logging.Handler;

import java.util.logging.Level;

import java.util.logging.Logger;

import com.jme3.app.SimpleApplication;

import com.jme3.input.KeyInput;

import com.jme3.input.MouseInput;

import com.jme3.input.controls.ActionListener;

import com.jme3.input.controls.KeyTrigger;

import com.jme3.input.controls.MouseButtonTrigger;

import com.jme3.niftygui.NiftyJmeDisplay;

import com.jme3.system.AppSettings;



import de.lessvoid.nifty.Nifty;



public class ShowCase extends SimpleApplication implements ActionListener {



private Nifty nifty;



//

//INIT

//


@Override

public void simpleInitApp() {

flyCam.setDragToRotate(true);

flyCam.setMoveSpeed(4);

//cam.setFrustumNear(cam.getFrustumNear() / 4);

NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);

nifty = niftyDisplay.getNifty();

initGUI();

Logger root = Logger.getLogger("");

Handler[] handlers = root.getHandlers();

for(int i = 0; i < handlers.length; i++) {

if(handlers instanceof ConsoleHandler) {

((ConsoleHandler) handlers).setLevel(Level.WARNING);

}

}

guiViewPort.addProcessor(niftyDisplay);

initInput();

} //End simpleInitApp()



private void initInput() {

String[] mappings = new String[] {

“FLYCAM_Left”,

“FLYCAM_Right”,

“FLYCAM_Up”,

“FLYCAM_Down”,

“FLYCAM_StrafeLeft”,

“FLYCAM_StrafeRight”,

“FLYCAM_Forward”,

“FLYCAM_Backward”,

“FLYCAM_ZoomIn”,

“FLYCAM_ZoomOut”,

“FLYCAM_RotateDrag”,

“FLYCAM_Rise”,

“FLYCAM_Lower”

};

// Remove last mapping for the flyByCam

inputManager.removeListener(flyCam);



// Change the mappings we don’t want

inputManager.addMapping(“FLYCAM_RotateDrag”, new MouseButtonTrigger(MouseInput.BUTTON_MIDDLE));

inputManager.addMapping(“FLYCAM_Rise”, new KeyTrigger(KeyInput.KEY_Q));

inputManager.addMapping(“FLYCAM_Lower”, new KeyTrigger(KeyInput.KEY_E));



// Recreate the mapping for the flyByCam

inputManager.addListener(flyCam, mappings);



inputManager.addMapping(“Select”, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));

inputManager.addMapping(“Delete”, new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));

inputManager.addMapping(“Edit”, new KeyTrigger(KeyInput.KEY_R));

inputManager.addMapping(“Toggle_Highlight”, new KeyTrigger(KeyInput.KEY_T));

inputManager.addListener(this, “Select”, “Edit”, “Toggle_Highlight”, “Delete”);

}



//

//GUI

//


private void initGUI() {

nifty.loadStyleFile(“nifty-default-styles.xml”);

nifty.loadControlFile(“nifty-default-controls.xml”);



nifty.addScreen(“start”, new EditorScreenBuilder2(this).build(nifty));

nifty.gotoScreen(“start”);

}//End initGUI();



//

//LSITENER

//


public void onAction(String name, boolean keyPressed, float tpf) {

if(name.equals(“Select”) && !keyPressed) {

System.out.println(“HELLO”);

} else if(name.equals(“Delete”) && !keyPressed) {

System.out.println(“HELLO”);

} else if(name.equals(“Edit”) && !keyPressed) {

System.out.println(“HELLO”);

} else if(name.equals(“Toggle_Highlight”) && !keyPressed) {

System.out.println(“HELLO”);

}

} //End onAction()



//

//MAIN

//


public static void main(String[] moep) {

SimpleApplication app = new ShowCase();

AppSettings settings = new AppSettings(true);

settings.setFrameRate(60);

settings.setResolution(1024, 768);

app.setSettings(settings);

app.setShowSettings(false);

app.start();

} //End main()

}

[/java]

Notify if any exception was threw.

There is no exception thrown. I removed the removal of nifty’s logging.

Nifty writes logs into the console with no care if the mouse is over the window or over the scene. But no exception.

I have exactly the same problem.



Before I click the scene nifty works fine.

But after I interact with my scene I cannot use the gui anymore.

No exceptions are thrown.

Is this issue with the nightly build?

Mine is from 25.02 (the previous one had other issues^^)

Ok, i committed some changes in jmeInputSystem on march 3 so it’s not what’s causing your issue.



Did you have this issue before?

The build from 20.02 worked fine. The 25th then broke the Bone.getAttachmentsNode() so I noticed that issue that late.

Is it safe to switch to today’s nightly? Then I would test that out.

@enum said:
Is it safe to switch to today's nightly?

Its never safe to switch to nightly. Thats why there is a stable branch..

It’s a bit weird… I created a new project and used JME from 20.02 and 07.02 and both showed the same error. But that’s impossible 'cause I started with the editor at 09.02 and it worked. I could select a geometry in the scene and after that press the edit button successfully. I will try again on my laptop where I did this (now I have a new desktop pc)

Yeah, I plan to switch to the next stable.

With safe I meant: relativly save so that the basic stuff works :wink:

@enum said:
With safe I meant: relativly save so that the basic stuff works ;)

Yeah, thats the main flaw when thinking about using nightly. Its not just about what works and what not. API might be there that disappears again, file formats might not have gotten the version number updates etc. etc.

Thats a good hint but at the moment I’m interested in helping finding that bug that seems to appear to more people than just me^^

On my laptop it didn’t work either (not even with the older version)… I can’t understand what happens there… I can click into the window and drag, that has the same effect as if I would drag with the mouse cursor inside the scene…

I will download the latest nightly and test with it.

Edit: no difference with latest nightly :frowning:

I can second (or third? fourth?) this problem.



interactOnClick works fine until I click away from nifty (ie on the scene). At this point, nifty does not capture mouse clicks and they just go through to the scene beneath.



Any updates?



Using October 2011 stable engine on OSX.

did anybody find any solution for this bug? please, don’t forget to fix it!! many persons have the same problem!!! thank you

OK, I’ll need to dig it up again to ask if anyone still having this problem.

Unfortunately I do. I use the nighty from the 24’th of june.



From what I see the class MouseInputEventProcessor stores the value ‘true’ in this field

[java]

private boolean lastButtonDown0;

[/java]

fter I click the scene.

The value is never changes and thus the method ‘canProcess’ always returns false.

1 Like

Yep - I’m still having it unfortunately.



I gave up in the end and build my app with swing components and a JME Swing canvas.

Maybe this problem only occurs when you use java api to build gui instead of xml files?

Does anyone has the same error while using nifty xml ???

the solution that I found is:



adding this code in the simpleInitApp:

inputManager.addMapping(“FLYCAM_RotateDrag”, new MouseButtonTrigger(MouseInput.BUTTON_MIDDLE));

inputManager.addMapping(“FLYCAM_RotateDrag”, new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));

inputManager.deleteTrigger(“FLYCAM_RotateDrag”, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));



and this one in simpleUpdate() method:

inputManager.deleteTrigger(“FLYCAM_RotateDrag”, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));



now I dont have more problem. I hope it continues like this.

regards

1 Like

Correct me if I’m wrong but fiddling with input triggers every update sounds a bit ugly. Nonetheless its the only solution so far (havent tested it myself)