stephengold / tonegodgui

ToneGod's graphical user-interface library for jMonkeyEngine3
Other
9 stars 5 forks source link

Add the ability to make the Screen stop/start listening to RawInputs #3

Open bob0bob opened 1 year ago

bob0bob commented 1 year ago

Need away to have Screen class stop/start listening to RawInputs. If use has a need to de-attach the screen from JME for a period of time the Screen is still listening to input and processing them. Use needs away to make it stop listening to RawInputs when it is de-attached from JME gui or control for the gui.

Adding 2 functions for stop/start, that the programmer can call to turn on/off the RawInputListening function.

stephengold commented 1 year ago

sounds like a job for an AppState

bob0bob commented 1 year ago

I thought about adding 2 functions inside the "Screen" class. it is a control. That appears to run the screen application.

I was thinking that when screen is removed from guiNode controls. The programmer would have to also call detachInputListener.

    /**
     * Call this function to setup the RawInputListener for this 
     * class.   By default the listener is already setup. 
     * This is used if for some reason you need to stop listening
     * to input but later on start listening again.
     * 
     */
    public void attachInputListener()
    {
        app.getInputManager().addRawInputListener(this);

    }

    /**
     * Call this function to tell class to stop listening to Raw
     * Inputs.  If you need to suspend the screen functions and
     * everything under that screen.  You can use this to make it
     * stop reacting.   This way you can detach the screen for a
     * period of time and re-attach it and have it start listening
     * to raw inputs again.
     */
    public void detachInputListener()
    {
        app.getInputManager().removeRawInputListener(this);

    }
stephengold commented 1 year ago

That seems like a step in the right direction.