diff --git a/backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/GwtInput.java b/backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/GwtInput.java index 0fd4de42f2c..d75daf7f87b 100644 --- a/backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/GwtInput.java +++ b/backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/GwtInput.java @@ -588,8 +588,9 @@ private void handleEvent (NativeEvent e) { hasFocus = true; this.justTouched = true; this.touched[0] = true; - this.pressedButtons.add(getButton(e.getButton())); - justPressedButtons[e.getButton()] = true; + final int button = getButton(e.getButton()); + this.pressedButtons.add(button); + justPressedButtons[button] = true; this.deltaX[0] = 0; this.deltaY[0] = 0; if (isCursorCatched()) { diff --git a/gdx/src/com/badlogic/gdx/Input.java b/gdx/src/com/badlogic/gdx/Input.java index 3efcd544621..21db6bec41a 100644 --- a/gdx/src/com/badlogic/gdx/Input.java +++ b/gdx/src/com/badlogic/gdx/Input.java @@ -653,7 +653,7 @@ public enum Peripheral { public boolean isButtonPressed (int button); /** Returns whether a given button has just been pressed. Button constants can be found in {@link Buttons}. On Android only the Buttons#LEFT - * constant is meaningful before version 4.0. + * constant is meaningful before version 4.0. On WebGL (GWT), only LEFT, RIGHT and MIDDLE buttons are supported. * * @param button the button to check. * @return true or false. */ diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/gwt/GwtInputTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/gwt/GwtInputTest.java index 37f009e4af1..a77d76d2d70 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/gwt/GwtInputTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/gwt/GwtInputTest.java @@ -19,6 +19,7 @@ import com.badlogic.gdx.Application; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Graphics; +import com.badlogic.gdx.Input; import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.graphics.Color; @@ -74,6 +75,15 @@ public void render () { if (Gdx.input.isKeyPressed(Keys.DOWN)) { y -= 1; } + if (Gdx.input.isButtonJustPressed(Input.Buttons.LEFT)){ + Gdx.app.log("GwtInputTest", "button pressed: LEFT"); + } + if (Gdx.input.isButtonJustPressed(Input.Buttons.MIDDLE)){ + Gdx.app.log("GwtInputTest", "button pressed: MIDDLE"); + } + if (Gdx.input.isButtonJustPressed(Input.Buttons.RIGHT)){ + Gdx.app.log("GwtInputTest", "button pressed: RIGHT"); + } } @Override diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/gwt/GwtTestWrapper.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/gwt/GwtTestWrapper.java index 4b1aef17a97..7770f6ebeb1 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/gwt/GwtTestWrapper.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/gwt/GwtTestWrapper.java @@ -359,7 +359,7 @@ public boolean isKeyJustPressed (int key) { @Override public boolean isButtonJustPressed (int button) { - return false; + return input.isButtonJustPressed(button); } @Override