GithubHelp home page GithubHelp logo

MenuItem: visual glitch about vis-ui HOT 4 CLOSED

kotcrab avatar kotcrab commented on August 16, 2024
MenuItem: visual glitch

from vis-ui.

Comments (4)

kotcrab avatar kotcrab commented on August 16, 2024

Could you create SSCCE? Looks like creating MenuItem with that text and shortcut is not enough to reproduce or it was somehow already fixed in latest VisUI.

from vis-ui.

code-disaster avatar code-disaster commented on August 16, 2024

Very odd. Still happening here even with the simplified application.

This is built with VisUI 0.9.0-SNAPSHOT and libGDX 1.6.5.

package com.codedisaster.demo;

import com.badlogic.gdx.*;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import com.kotcrab.vis.ui.VisUI;
import com.kotcrab.vis.ui.widget.*;

public class MenuItemDemo extends ApplicationAdapter {

    OrthographicCamera screenCamera;

    Stage ui;
    InputMultiplexer input;

    @Override
    public void create () {
        VisUI.load();
    }

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

    @Override
    public void resize(int width, int height) {
        if (ui != null) {
            ui.dispose();
        }

        screenCamera = new OrthographicCamera(width, height);

        ui = new Stage(new ScreenViewport(screenCamera));
        setupUI();

        input = new InputMultiplexer();
        input.addProcessor(ui);
        Gdx.input.setInputProcessor(input);
    }

    @Override
    public void render () {
        ui.act(Gdx.graphics.getRawDeltaTime());
        ui.draw();
    }

    private void setupUI() {
        Table root = new Table();

        MenuBar menuBar = new MenuBar();
        root.add(menuBar.getTable()).top().fillX().expandX().row();

        Menu viewMenu = new Menu("View");
        menuBar.addMenu(viewMenu);

        MenuItem showDebugGridItem = new MenuItem("Toggle tile grid");
        viewMenu.addItem(showDebugGridItem);
        showDebugGridItem.setShortcut(Input.Keys.SYM, Input.Keys.G);

        root.left().top().pad(8).setFillParent(true);
        ui.addActor(root);
    }

}

from vis-ui.

code-disaster avatar code-disaster commented on August 16, 2024

Ah! I found it! I need to call MenuItem.setShortcut() before Menu.addItem().

from vis-ui.

kotcrab avatar kotcrab commented on August 16, 2024

Guess it should call invalidateHierarchy after setting shortcut, I'll add that. setShorcut returns MenuItem so you can chain it with item creation.

Btw since 0.8.2 setShorcut(int... keycodes) is OS dependent, if you call it with setShortcut(Input.Keys.CONTROL_LEFT, Input.Keys.G), it will be Ctrl+G on Win and Linux, and ⌘G on Mac.

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.