diff --git a/engine/src/niftygui/com/jme3/niftygui/InputSystemJme.java b/engine/src/niftygui/com/jme3/niftygui/InputSystemJme.java index 937ce64e0..8a2d1c702 100644 --- a/engine/src/niftygui/com/jme3/niftygui/InputSystemJme.java +++ b/engine/src/niftygui/com/jme3/niftygui/InputSystemJme.java @@ -89,6 +89,37 @@ public class InputSystemJme implements InputSystem, RawInputListener { boolean result = nifty.update(); } + private void onTouchEventQueued(TouchEvent evt, NiftyInputConsumer nic) { + boolean consumed = false; + + x = (int) evt.getX(); + y = (int) (height - evt.getY()); + + switch (evt.getType()) { + case DOWN: + consumed = nic.processMouseEvent(x, y, 0, 0, false); + isDragging = true; + niftyOwnsDragging = consumed; + if (consumed){ + evt.setConsumed(); + } + + break; + + case UP: + if (niftyOwnsDragging){ + consumed = nic.processMouseEvent(x, y, 0, buttonIndex, pressed); + if (consumed){ + evt.setConsumed(); + } + } + + isDragging = false; + niftyOwnsDragging = false; + break; + } + } + private void onMouseMotionEventQueued(MouseMotionEvent evt, NiftyInputConsumer nic) { x = evt.getX(); y = height - evt.getY(); @@ -175,7 +206,8 @@ public class InputSystemJme implements InputSystem, RawInputListener { inputQueue.add(evt); } - public void onTouchEvent(TouchEvent evt) { + public void onTouchEvent(TouchEvent evt) { + inputQueue.add(evt); } public void forwardEvents(NiftyInputConsumer nic) { @@ -189,6 +221,8 @@ public class InputSystemJme implements InputSystem, RawInputListener { onMouseButtonEventQueued( (MouseButtonEvent)evt, nic); }else if (evt instanceof KeyInputEvent){ onKeyEventQueued( (KeyInputEvent)evt, nic); + }else if (evt instanceof TouchEvent){ + onTouchEventQueued( (TouchEvent)evt, nic); } }