Scene2d Window now detecting move

Anything libgdx related goes here!

Scene2d Window now detecting move

Postby gamedev101 » Wed Jan 29, 2020 6:37 pm

I'm using a Scene2d Window and when clicking on title bar of it and then trying to move it via mouse it doesn't move most of the time. Sometimes depending on where
you click on the title it grabs the window and allows you to move it. I am using a WindowStyle to add a bitmap to the window and believe this is possibly causing the issue but I'm not sure?

Code as follows (I've ommitted the override methods to keep it small)

Code: Select all
public class QuestWindow extends ApplicationAdapter implements InputProcessor {
    private Stage stage;
    private WindowWithTopRightCornerCloseButton windowWithTopRightCornerCloseButton;

    public QuestWindow() {

    public void create() {
        stage = new Stage();
        windowWithTopRightCornerCloseButton = new WindowWithTopRightCornerCloseButton();
        windowWithTopRightCornerCloseButton.setSize(600, 600);
        windowWithTopRightCornerCloseButton.setPosition( - windowWithTopRightCornerCloseButton.getWidth()/2, - windowWithTopRightCornerCloseButton.getHeight()/2);
        InputMultiplexer multiplexer = new InputMultiplexer(this);
    public void dispose() {

    public void render() {, 0, 0, 1);;

And the window class itself:

Code: Select all
public class WindowWithTopRightCornerCloseButton extends Window {

    private static final WindowStyle windowStyle;
    private static final ImageButtonStyle closeButtonStyle;

    static {
        TextureAtlas textureAtlas = new TextureAtlas(Gdx.files.absolute(IFileName.HUDroot + "/windows.pack"));
        windowStyle = new WindowStyle(new BitmapFont(), Color.BLACK, new TextureRegionDrawable(textureAtlas.findRegion("window-1-background")));
        closeButtonStyle = new ImageButtonStyle();
        closeButtonStyle.imageUp = new TextureRegionDrawable(textureAtlas.findRegion("window-1-close-button"));

    public WindowWithTopRightCornerCloseButton() {
        super("", windowStyle);
        getTitleTable().add(closeButton).size(38, 38).padRight(20).padTop(20);

I'm not really sure why this is happening, the code I found on the internet and looks ok to me. I just want to be able to put a bitmap over the scene2d window.

Any help is much appreciated.

Posts: 13
Joined: Thu Nov 28, 2019 7:43 pm

Re: Scene2d Window now detecting move

Postby shatterblast » Wed Jan 29, 2020 10:26 pm

You might try putting your Button in a Container, and then, add the Container to the Window itself in case of any conflicts.
Posts: 653
Joined: Sun Jul 06, 2014 1:14 pm

Re: Scene2d Window now detecting move

Postby gamedev101 » Thu Jan 30, 2020 8:27 am

The close button listener actually does work but only for one of the windows - I did try use an inputmultiplexer but the same. Its just moving the window around doesn't, it is as though checking when clicked in the caption bar isn't being detected correctly, you can click along the caption bar and sometimes it does get captured but then move the window and the position of where click detection is will then be somewhere else in the caption bar.

Possibly something to do with the bounds or viewport of the window?

Posts: 13
Joined: Thu Nov 28, 2019 7:43 pm

Return to Libgdx

Who is online

Users browsing this forum: MSN [Bot] and 1 guest