Nifty : applied patch posted by iwgeric in this thread http://jmonkeyengine.org/groups/android/forum/topic/error-with-nifty-and-awt/?topic_page=2&num=15#post-147332
fixes nifty interaction on touch event on android. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8971 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user