Search in sources :

Example 6 with Type

use of com.badlogic.gdx.scenes.scene2d.InputEvent.Type in project gaiasky by langurmonkey.

the class OwnImageButton method initialize.

private void initialize() {
    cursor = SystemCursor.Hand;
    this.addListener(event -> {
        if (event instanceof InputEvent) {
            Type type = ((InputEvent) event).getType();
            if (type == Type.enter) {
                if (!me.isDisabled())
                    Gdx.graphics.setSystemCursor(cursor);
                return true;
            } else if (type == Type.exit) {
                Gdx.graphics.setSystemCursor(SystemCursor.Arrow);
                return true;
            }
        }
        return false;
    });
}
Also used : Type(com.badlogic.gdx.scenes.scene2d.InputEvent.Type) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

Example 7 with Type

use of com.badlogic.gdx.scenes.scene2d.InputEvent.Type in project gaiasky by langurmonkey.

the class ColorPicker method initialize.

protected void initialize() {
    this.addListener(event -> {
        if (event instanceof InputEvent) {
            InputEvent ie = (InputEvent) event;
            Type type = ie.getType();
            // Click
            if ((type == Type.touchDown) && (ie.getButton() == Buttons.LEFT)) {
                // Launch color picker window
                ColorPickerDialog cpd = new ColorPickerDialog(name, color, stage, skin);
                cpd.setAcceptRunnable(() -> {
                    // Set color and run runnable, if any
                    setPickedColor(cpd.color);
                    if (newColorRunnable != null) {
                        newColorRunnable.run();
                    }
                });
                cpd.show(stage);
            } else if (type == Type.enter) {
                Gdx.graphics.setSystemCursor(SystemCursor.Hand);
            } else if (type == Type.exit) {
                Gdx.graphics.setSystemCursor(SystemCursor.Arrow);
            }
            return true;
        }
        return false;
    });
}
Also used : Type(com.badlogic.gdx.scenes.scene2d.InputEvent.Type)

Aggregations

Type (com.badlogic.gdx.scenes.scene2d.InputEvent.Type)7 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)5 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)4 Vector2 (com.badlogic.gdx.math.Vector2)1 ChangeEvent (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent)1