Way of disabling the SelectBox (tonegodgui)?

Hello, i’ve recently struggled to find a way to disable the SelectBox object from tonegodGUI. There is a method calles setIsEnabled() but is screws up the game. I’ve also tried to call setIgnoreMouseLeftButton() without any effect. So there’s my question, is there a way of disabling a SelectBox(or a ComboBox)??

I checked my old lobby screen and it used setIsEnabled() to disable selectBox. I remember it working then. It was a loooong time ago. No idea if a bug was introduced in the toneGodGUI api since then for that since I haven’t used that method since then.

How does it screw up the game?

It makes the SelectBoxes have a ~5sec delay when clicked (only from the moment when someone connects to the lobby)

The way I see it, is that there is no link between toneGodGUI and network. So maybe do a small test case where you check if disabling it still brings lag. If it doesn’t, then it means it’s linked to some of your code.

The only issue i know related to SelectBox being the closest to what you said is :

SelectBox.getIsEnabled() 

unless you’re using this to know the state of the SelectBox before doing anything, SelectBox work just fine concerning enabling and disabling.

As exemple :

package test;

import com.jme3.app.SimpleApplication;
import com.jme3.input.ChaseCamera;
import com.jme3.input.event.MouseButtonEvent;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import java.util.logging.Level;
import java.util.logging.Logger;
import tonegod.gui.controls.buttons.ButtonAdapter;
import tonegod.gui.controls.lists.SelectBox;
import tonegod.gui.controls.text.Label;
import tonegod.gui.controls.windows.Window;
import tonegod.gui.core.Screen;

/**
 *
 * @author roah
 */
public class ToneGodTestCase extends SimpleApplication {

    public static void main(String[] args) {
        ToneGodTestCase app = new ToneGodTestCase();
        Logger.getLogger("").setLevel(Level.SEVERE);
        app.start();
    }
    private Screen screen;
    private Label label;
    private SelectBox automatedSelectBox;
    private boolean playTimer = true;
    private boolean isAuto;

    @Override
    public void simpleInitApp() {

        screen = new Screen(this);
        guiNode.addControl(screen);
        runSelectBox();

        Box b = new Box(1, 1, 1);
        Geometry geom = new Geometry("Box", b);

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.getAdditionalRenderState().setWireframe(true);
        mat.setColor("Color", ColorRGBA.Blue);
        geom.setMaterial(mat);

        rootNode.attachChild(geom);

        getFlyByCamera().setEnabled(false);
        ChaseCamera chaseCam = new ChaseCamera(cam, geom, inputManager);
        chaseCam.setSmoothMotion(true);
    }

    private void runSelectBox() {
        Vector2f size = new Vector2f(450, 300);
        Vector2f pos = new Vector2f(getCamera().getWidth() / 2 - size.x / 2, getCamera().getHeight() / 2 - size.y / 2);
        Window win = new Window(screen, pos, size);
        win.setWindowTitle("Hello World");
        /**
         * Generate the select box. (the one handled by button)
         * This is the one who doesn't work since it use the SelectBox.getIsEnabled() to switch
         */
        String[] solarSystem = new String[]{"Mercury", "Venus", "Uranus", "Neptune"};
        final SelectBox selectBox = new SelectBox(screen, new Vector2f(5, 5)) {
            @Override
            public void onChange(int selectedIndex, Object value) {
//                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }
        };
        for (String s : solarSystem) {
            selectBox.addListItem(s, System.nanoTime());
        }
        win.addWindowContent(selectBox);

      /**
         * Hide and show button.
         */
        float nextElement = selectBox.getChildElementById(selectBox.getUID() + ":ArrowDown").getWidth()
                + selectBox.getPosition().x + selectBox.getWidth() + 5;
        ButtonAdapter btnA = new ButtonAdapter(screen, new Vector2f(nextElement, 5),
                new Vector2f(screen.getStyle("Button").getVector2f("defaultSize").x, selectBox.getHeight())) {
            @Override
            public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
                if (selectBox.getIsVisible()) {
                    selectBox.setIsVisible(false);
                    setText("show...");
                } else {
                    selectBox.setIsVisible(true);
                    setText("hide...");
                }
            }
        };
        btnA.setText("hide...");
        win.addWindowContent(btnA);
        /**
         * disable and automatedEnabled button.
         */
        selectBox.setIsEnabled(true);
        ButtonAdapter btnB = new ButtonAdapter(screen, new Vector2f(btnA.getPosition().x + btnA.getWidth() + 5, 5),
                new Vector2f(screen.getStyle("Button").getVector2f("defaultSize").x, selectBox.getHeight())) {
            @Override
            public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
                // This part doesn't work since it doesn't return the right value.
                if (selectBox.getIsEnabled()) {
                    setText("enable...");
                    selectBox.setIsEnabled(false);
                } else {
                    selectBox.setIsEnabled(true);
                    setText("disable...");
                }
            }
        };
        btnB.setText("disable...");
        win.addWindowContent(btnB);

        /**
         * Generate an automated disable & automatedEnabled selectBox with a time helper.
         */
        label = new Label(screen, new Vector2f(selectBox.getWidth()
                + selectBox.getChildElementById(
                selectBox.getUID() + ":ArrowDown").getWidth() + 10,
                selectBox.getHeight() + 5), new Vector2f(325, 35));
        automatedSelectBox = new SelectBox(screen, new Vector2f(5,
                selectBox.getHeight() + 10)) {
            @Override
            public void onChange(int selectedIndex, Object value) {
                setLabelText();
                if(isAuto){
                    automatedSelectBox.setIsEnabled(automatedEnabled);
                    isAuto = false;
                }
            }
        };
        for (String s : solarSystem) {
            automatedSelectBox.addListItem(s, System.nanoTime());
        }

        win.addWindowContent(label);
        win.addWindowContent(automatedSelectBox);


        /**
         * Button used to stop the timer.
         */
        selectBox.setIsEnabled(true);
        ButtonAdapter btnC = new ButtonAdapter(screen, new Vector2f(win.getDimensions().x - 75 - 5, btnA.getHeight() + 10),
                new Vector2f(75, selectBox.getHeight())) {
            @Override
            public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
                if (getText().equals("Stop")) {
                    setText("Play");
                    playTimer = false;
                } else {
                    setText("Stop");
                    playTimer = true;
                }
            }
        };
        btnC.setText("Stop");
        win.addWindowContent(btnC);

        screen.addElement(win);
    }

    private void setLabelText() {
        label.setText(" is "
                + (automatedEnabled ? "enable..." : "disabled... ")
                + (int) currentTimer + " s before switching.");
    }
    float currentTimer, delay = 4.9f;
    boolean automatedEnabled = false;

    @Override
    public void simpleUpdate(float tpf) {
        if (playTimer && (currentTimer -= tpf) <= 0.9f) {
            currentTimer = delay;
            if (automatedSelectBox.getSelectIndex() + 1 >= automatedSelectBox.getListItems().size()) {
                automatedSelectBox.setSelectedIndex(0);
            } else {
                automatedEnabled = !automatedEnabled;
                isAuto = true;
                automatedSelectBox.setSelectedIndexWithCallback(automatedSelectBox.getSelectIndex() + 1);
            }
        }
        setLabelText();
    }
}

On the exemple only the automated SelectBox work properly, the first one will not.