1

I want to programically click on the button1 whenever I pressed on button2 (after clicked on button2 the button1 show style.down then style.up and do function in the clicklistener). I found similiar issue on that post but doesnt work for me.

In android I just have to call the performAction() method, but I couldnt find similiar method using LibGDX Library

Expiredmind
  • 788
  • 1
  • 8
  • 29

1 Answers1

1

I figure it out :

The solution (Inspired by this post)

button2.addListener(new ClickListener(){
            @Override
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
                InputEvent event1 = new InputEvent();
                event1.setType(InputEvent.Type.touchDown);
                button1.fire(event1);
            return true;
            }
            @Override
            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {

                InputEvent event2 = new InputEvent();
                event2.setType(InputEvent.Type.touchUp);
                button1.fire(event2);
              doSmth();

            }
        });
Expiredmind
  • 788
  • 1
  • 8
  • 29
  • I actually wanted to look into this since I had no clue and nothing turned up in a first search. Nice question and well answered. – Madmenyo Jul 27 '17 at 08:22