javaslick2dnifty-gui

Make Nifty GUI ScreenController swallow input


In my Slick2D game, I'm extending NiftyOverlayBasicGameState, using Nifty GUI overlays, and specifying a PlainSlickInputSystem. For most overlaid screens I'd like Nifty GUI to ignore all input and pass it through to the GameState.

For one particular screen, I'd like to prevent all input getting through to the underlying GameState - but I only want this to happen for one screen, not all of them.

Is this possible using Nifty GUI, or am I taking the wrong approach? Can individual screens specify different input handling behaviour? Or should I instead be using a separate GameState with a different Niftyu GUI input system for the one screen where I want Nifty GUI to handle the input?


Solution

  • There are several options available. The most basic one would be to have some sort of background layer and set visibleToMouse="true" for it. This way all of your mouse events will hit that layer and the mouse events will be marked as processed by Nifty. This should prevent the events from being forwarded to the GameState.