fixes nifty interaction on touch event on android.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8971 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 13 years ago
parent baba9d6b47
commit 950276679e
  1. 36
      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);
}
}

Loading…
Cancel
Save