During initialization, I construct my gui scene. When the state is enabled, I attach my gui scene to the gui view port. The scene updates and displays properly when I do this, but none of the buttons in the scene respond to input, even though all other buttons do.
Here is my code:
@Override
protected void initialize(Application app) {
windowSize = new Vector2f(app.getContext().getSettings().getWidth(),
app.getContext().getSettings().getHeight());
if (app instanceof SimpleApplication) {
vp = ((SimpleApplication)app).getGuiViewPort();
}
else {
LOG.log(Level.INFO, "Unable to find the default GUI view port. Must be set manually.");
}
node.setLocalTranslation(0f, 0f, 20f);
node.setCullHint(Spatial.CullHint.Never);
node.setQueueBucket(RenderQueue.Bucket.Gui);
node.attachChild(createBackgroundBlocker(-10f, new ColorRGBA(0f, 0f, 0f, .7f)));
node.attachChild(gui);
initGlobalButtons();
gui.addChild(varList);
gui.setLocalTranslation(0f, windowSize.y, 0f);
varLayout = new BoxLayout();
varList.setLayout(varLayout);
}
Is your background blocker maybe sorting on top of your GUI?
Wait! Are you swapping out the whole guiNode?
Lemur has automatically registered to do picking on the existing gui node. If you swap it out then you will have to remove the old registration and add your new one.
…but now I wonder what you are really trying to do because I can’t imagine a use-case where all of this is required.
Why not just use the existing gui node for your gui?
The gui is a developer tool which is supposed to able to display on top of everything at any time during the program. If the regular gui node is covered up by something (like with split-screen gui) in the game, then the dev can move this gui to another viewport to ensure it remains on top.
Plus, if the dev ever dumps all the existing gui node’s children, I don’t want my gui to get dumped too.
Before going down that path; why are you attaching a whole new gui node? Wouldnt it be simpler to attach something to the normal gui node? (And use z ordering to get things on top of one annother)
If the user creates a post view, the existing gui (and my gui) will be covered up. My gui should always be on top, which is why I allow the user to set the viewport in which the gui is rendered.
I thought maybe my background blocker was eating up all the picks, but the problem did not resolve when I removed it.
Edit: I just noticed that other gui does work when the tool’s state is enabled. After the tool’s state is disabled again, the other gui goes back to not working.
@Override
protected void onEnable() {
// This is how the tool gets displayed. Another state
// handles the viewport and gui root, and this state
// simply tags on when it wants to display.
guiRoot.getGuiRoot().attachChild(scene);
GuiGlobals.getInstance().requestCursorEnabled(this);
GuiGlobals.getInstance().requestFocus(scene);
}
@Override
protected void onDisable() {
scene.removeFromParent();
GuiGlobals.getInstance().releaseCursorEnabled(this);
GuiGlobals.getInstance().releaseFocus(scene);
}
Anyway, I think probably your application’s GUI never requested cursor enabled and so when you release it you are telling Lemur that nothing is using the GUI anymore and the mouse should be turned off.
Hmm, I addressed that, but it didn’t make any difference.
This is what I narrowed it down to:
When the tool scene node (with or without children) is attached to my root gui node, the other gui elements react to the mouse as expected, otherwise they don’t react as expected.
Here are the gui scenes in question:
gui view port
__/ \______
/ \
normal gui node my gui root
| |
| |
other gui elements my gui scene <--when this is attached, it works
|
|
tool buttons & gizmos