Example usage for com.badlogic.gdx.scenes.scene2d.utils ClickListener setTapCountInterval

List of usage examples for com.badlogic.gdx.scenes.scene2d.utils ClickListener setTapCountInterval

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d.utils ClickListener setTapCountInterval.

Prototype

public void setTapCountInterval(float tapCountInterval) 

Source Link

Usage

From source file:com.uwsoft.editor.gdx.sandbox.SandboxInputAdapter.java

License:Apache License

public void initItemListeners(final IBaseItem eventItem) {
    ClickListener listener = new ClickListener() {

        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            super.touchDown(event, x, y, pointer, button);

            return itemTouchDown(eventItem, event, x, y, button);
        }//from  w w w  . j  ava 2s . co  m

        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            super.touchUp(event, x, y, pointer, button);

            itemTouchUp(eventItem, event, x, y, button);

            if (getTapCount() == 2) {
                // this is double click
                itemDoubleClick(eventItem, event, x, y, button);
            }
        }

        public void touchDragged(InputEvent event, float x, float y, int pointer) {
            itemTouchDragged(eventItem, event, x, y);
        }
    };

    // tap count interval to correctly manage double clicks
    // if longer then 0.5 second it's not double click
    listener.setTapCountInterval(0.5f);

    // finally adding this huge listener
    ((Actor) eventItem).addListener(listener);
}

From source file:com.uwsoft.editor.gdx.sandbox.SandboxInputAdapter.java

License:Apache License

public void initSandboxEvents() {
    ClickListener listener = new ClickListener() {

        public boolean scrolled(InputEvent event, float x, float y, int amount) {
            return sandboxMouseScrolled(x, y, amount);
        }/*from  w  w w  .java  2 s . c  o m*/

        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            super.touchDown(event, x, y, pointer, button);

            lastX = Gdx.input.getX();
            lastY = Gdx.input.getY();

            return sandboxTouchDown(event, x, y, button);
        }

        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            super.touchUp(event, x, y, pointer, button);

            sandboxTouchUp(event, x, y, button);

            if (getTapCount() == 2 && button == Input.Buttons.LEFT) {
                sandboxDoubleClick(event, x, y);
            }
        }

        public void touchDragged(InputEvent event, float x, float y, int pointer) {
            sandboxTouchDragged(event, x, y);
        }

        public boolean keyDown(InputEvent event, int keycode) {

            return sandboxKeyDown(keycode);

        }

        public boolean keyUp(InputEvent event, int keycode) {
            return sandboxKeyUp(keycode);
        }
    };

    sandbox.getSandboxStage().addListener(listener);

    listener.setTapCountInterval(0.5f);

    ClickListener transformationListeners = new ClickListener() {

        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            if (sandbox.currTransformHost != null && sandbox.currTransformType >= 0) {
                sandbox.isResizing = true;
                sandbox.transformationHandler.setTransforming(sandbox.currTransformType,
                        (Actor) sandbox.currTransformHost);
            }
            return super.touchDown(event, x, y, pointer, button);
        }

        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            super.touchUp(event, x, y, pointer, button);

            if (sandbox.transformationHandler.isResizing()) {

            }
            if (sandbox.isResizing == true && sandbox.transformationHandler.isResizing()) {
                ((IBaseItem) sandbox.transformationHandler.getHost()).updateDataVO();
            }
            sandbox.isResizing = false;

            sandbox.transformationHandler.clear();
            sandbox.currTransformHost = null;
            sandbox.getSandboxStage().setCursor(Cursor.DEFAULT_CURSOR);
        }

        public void touchDragged(InputEvent event, float x, float y, int pointer) {
            if (!sandbox.isResizing) {
                return;
            }

            sandbox.transformationHandler.touchDragged(event, x, y);

            sandbox.getUIStage().updateCurrentItemState();

            SelectionRectangle selectionRectangle = sandbox.getSelector().getCurrentSelection()
                    .get(sandbox.transformationHandler.getHost());

            //TODO: sometimes it is null, find out why
            if (selectionRectangle != null) {
                selectionRectangle.update();
            }
        }
    };

    // add the listener
    sandbox.getSandboxStage().addListener(transformationListeners);
}

From source file:com.uwsoft.editor.gdx.ui.layer.UILayerBox.java

License:Apache License

public void initContent() {
    layers = stage.getSandbox().getCurrentScene().dataVO.composite.layers;
    contentGroup.clear();// w w  w.jav a  2 s. c  om
    layerActors.clear();
    float heightSize = layers.size() * 20;
    float minSize = 217;
    if (heightSize < minSize)
        heightSize = minSize;
    contentGroup.setHeight(heightSize);
    contentGroup.setX(3);

    checkForSelectedIndexChanges();

    for (int i = 0; i < layers.size(); i++) {
        LayerItem itm = new LayerItem(layers.get(i), stage.getSandbox());
        itm.initListeners();
        itm.setY(contentGroup.getHeight() - (layers.size() - i - 1) * itm.getHeight());
        contentGroup.addActor(itm);
        layerActors.add(itm);
        dragAndDrop.addSource(new LayerItemSource(itm, this));
        dragAndDrop.addTarget(new LayerItemTarget(itm, this));

        if (i == currentSelectedLayerIndex)
            itm.select();

        final int iter = i;
        ClickListener listener = new ClickListener() {
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
                super.touchDown(event, x, y, pointer, button);
                return true;
            }

            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
                super.touchUp(event, x, y, pointer, button);
                if (isLayerDragging) {
                    isLayerDragging = false;
                    return;
                }

                if (layers.get(iter).isLocked)
                    return;

                currentSelectedLayerIndex = iter;
                selectItem(iter);
                stage.getSandbox().getSelector().selectItemsByLayerName(layers.get(iter).layerName);

                if (getTapCount() == 2) {
                    showRenameDialog();
                }
                if (layers.get(iter).isLocked || layers.get(iter).isVisible) {
                    return;
                }

            }
        };

        listener.setTapCountInterval(0.5f);
        itm.addListener(listener);
    }
}