Search in sources :

Example 1 with SimStack

use of com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimStack in project skin-composer by raeleus.

the class StackListeners method stackNameListener.

public static EventListener stackNameListener(final DialogSceneComposer dialogSceneComposer) {
    var simStack = (SimStack) dialogSceneComposer.simActor;
    var textField = new TextField("", skin, "scene");
    var popTableClickListener = new PopTableClickListener(skin) {

        {
            getPopTable().key(Keys.ESCAPE, popTable::hide);
        }

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            dialogSceneComposer.getStage().setKeyboardFocus(textField);
            textField.setSelection(0, textField.getText().length());
            update();
        }

        public void update() {
            var popTable = getPopTable();
            popTable.clearChildren();
            var label = new Label("Name:", skin, "scene-label-colored");
            popTable.add(label);
            popTable.row();
            textField.setText(simStack.name);
            popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
            textField.addListener(ibeamListener);
            textField.addListener(new TextTooltip("The name of the Stack to allow for convenient searching via Group#findActor().", tooltipManager, skin, "scene"));
            textField.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    dialogSceneComposer.events.stackName(textField.getText());
                }
            });
            textField.addListener(new InputListener() {

                @Override
                public boolean keyDown(InputEvent event, int keycode) {
                    if (keycode == Input.Keys.ENTER || keycode == Keys.NUMPAD_ENTER) {
                        popTable.hide();
                        return true;
                    } else {
                        return false;
                    }
                }
            });
            dialogSceneComposer.getStage().setKeyboardFocus(textField);
            textField.setSelection(0, textField.getText().length());
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : SimStack(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimStack) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) TextTooltip(com.badlogic.gdx.scenes.scene2d.ui.TextTooltip) InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) Actor(com.badlogic.gdx.scenes.scene2d.Actor) TextField(com.badlogic.gdx.scenes.scene2d.ui.TextField) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

Aggregations

Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)1 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)1 TextField (com.badlogic.gdx.scenes.scene2d.ui.TextField)1 TextTooltip (com.badlogic.gdx.scenes.scene2d.ui.TextTooltip)1 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)1 SimStack (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimStack)1 PopTableClickListener (com.ray3k.stripe.PopTableClickListener)1