GithubHelp home page GithubHelp logo

Comments (15)

kotcrab avatar kotcrab commented on August 16, 2024

Does that happen with normal TextField? If so then this is a libGDX issue.

from vis-ui.

nikoliazekter avatar nikoliazekter commented on August 16, 2024

No, only with VisTextField.

from vis-ui.

kotcrab avatar kotcrab commented on August 16, 2024

Ok then, will take a look.

from vis-ui.

kotcrab avatar kotcrab commented on August 16, 2024

Also, could you post SSCCE, please?

from vis-ui.

kotcrab avatar kotcrab commented on August 16, 2024

I cannot reproduce with this:

public class TestIssue50 {

    public static void main (String[] args) {
        LwjglApplicationConfiguration c = new LwjglApplicationConfiguration();
        c.width = 1280;
        c.height = 720;
        new LwjglApplication(new TestIssue50Application(), c);
    }

}

class TestIssue50Application extends ApplicationAdapter {
    private Stage stage;

    @Override
    public void create () {
        VisUI.load();
        stage = new Stage(new ScreenViewport());
        Table table = new Table();
        table.setFillParent(true);
        table.add(getNewVisTextField()).row();
        table.add(getNewGdxTextField()).row();
        stage.addActor(table);
        Gdx.input.setInputProcessor(new InputMultiplexer(stage, new TestInputProcessor()));
    }

    private VisTextField getNewVisTextField () {
        return new VisTextField("VisTextField");
    }

    private TextField getNewGdxTextField () {
        TextFieldStyle style = new TextFieldStyle(VisUI.getSkin().get(TextFieldStyle.class));
        return new TextField("GdxTextField", style);
    }

    @Override
    public void resize (int width, int height) {
        stage.getViewport().update(width, height, true);
    }

    @Override
    public void render () {
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        stage.act(Gdx.graphics.getDeltaTime());
        stage.draw();
    }

    @Override
    public void dispose () {
        VisUI.dispose();
        stage.dispose();
    }

    class TestInputProcessor extends InputAdapter {

        @Override
        public boolean keyDown (int keycode) {
            System.out.println("PROCESSED, KEYCODE:" + keycode);
            return false;
        }

    }

}

from vis-ui.

nikoliazekter avatar nikoliazekter commented on August 16, 2024

I've just tried to experiment a bit and I found out that I can get the behaviour I described only if VisTextField is an actor inside a Node in a Tree (or VisTree, doesn't matter). libgdx TextField doesn't have this issue in the same conditons though.

from vis-ui.

intrigus avatar intrigus commented on August 16, 2024

Please provide a SSCCE.

from vis-ui.

nikoliazekter avatar nikoliazekter commented on August 16, 2024
public class TestIssue50 {

    public static void main (String[] args) {
        LwjglApplicationConfiguration c = new LwjglApplicationConfiguration();
        c.width = 1280;
        c.height = 720;
        new LwjglApplication(new TestIssue50Application(), c);
    }

}

class TestIssue50Application extends ApplicationAdapter {
    private Stage stage;

    @Override
    public void create () {
        VisUI.load();
        stage = new Stage(new ScreenViewport());
        Table table = new Table();
        table.setFillParent(true);
        VisTree tree = new VisTree();
        table.add(tree);
        tree.add(new Node(getNewVisTextField()));
        tree.add(new Node(getNewGdxTextField()));
        stage.addActor(table);
        Gdx.input.setInputProcessor(new InputMultiplexer(stage, new TestInputProcessor()));
    }

    private VisTextField getNewVisTextField () {
        return new VisTextField("VisTextField");
    }

    private TextField getNewGdxTextField () {
        TextFieldStyle style = new TextFieldStyle(VisUI.getSkin().get(TextFieldStyle.class));
        return new TextField("GdxTextField", style);
    }

    @Override
    public void resize (int width, int height) {
        stage.getViewport().update(width, height, true);
    }

    @Override
    public void render () {
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        stage.act(Gdx.graphics.getDeltaTime());
        stage.draw();
    }

    @Override
    public void dispose () {
        VisUI.dispose();
        stage.dispose();
    }

    class TestInputProcessor extends InputAdapter {

        @Override
        public boolean keyDown (int keycode) {
            System.out.println("PROCESSED, KEYCODE:" + keycode);
            return false;
        }

    }

}

from vis-ui.

intrigus avatar intrigus commented on August 16, 2024

Which VisUI version do you use?

from vis-ui.

nikoliazekter avatar nikoliazekter commented on August 16, 2024

VisUI 0.9.1 and libGDX 1.7.0

from vis-ui.

nikoliazekter avatar nikoliazekter commented on August 16, 2024

I got another interesting behaviour. When I use VisTextField after clicking on some button my game starts getting input again but only keyDown events, not keyUp. When I use TextField I just can't get any key events anymore. Btw it's not Tree issue, it can be reproduced anywhere.

from vis-ui.

kotcrab avatar kotcrab commented on August 16, 2024

Should work now.

from vis-ui.

nikoliazekter avatar nikoliazekter commented on August 16, 2024

After I call VisTextField.focusLost() I still can get only keyDown events. I can get keyUp only after I press some button. You should add FocusManager.getFocus(getStage()); in focusLost().

from vis-ui.

kotcrab avatar kotcrab commented on August 16, 2024

That's not how it works, focusLost and focusGained are listener methods called by FocusManager.
You never manually call them.

To take focus you need to call FocusManager.getFocus(stage) or stage.setKeyboardFocus(null) (but the second way would left focus border still visible on widget)

from vis-ui.

nikoliazekter avatar nikoliazekter commented on August 16, 2024

Makes sense now, thanks!

from vis-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.