upgraded nifty and nifty-default-controls to nightly build of 2011-03-24. Also fixed the AwtMouseInput and removed some ununsed imports. The com.jme3.niftygui.InputSystem has been changed as well to correspond with the new Nifty way of working with mouse events. It now uses the new MouseInputEventQueue and the new NiftyMouseInputEvent.

There is still an issue with the mouse buttons besides the first mouse button. These should be picked up by nifty, but for some reason are not triggering a MouseButtonEvent. This is something Kirril will need to take a look at.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7114 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rac..om 14 years ago
parent 8348011344
commit 8cdef21af6
  1. BIN
      engine/lib/niftygui/nifty-1.3-SNAPSHOT.jar
  2. BIN
      engine/lib/niftygui/nifty-default-controls-1.3-SNAPSHOT.jar
  3. 14
      engine/src/desktop/com/jme3/input/awt/AwtMouseInput.java
  4. 31
      engine/src/niftygui/com/jme3/niftygui/InputSystemJme.java

@ -32,11 +32,6 @@
package com.jme3.input.awt;
import com.jme3.input.MouseInput;
import com.jme3.input.RawInputListener;
import com.jme3.input.event.MouseButtonEvent;
import com.jme3.input.event.MouseMotionEvent;
import de.lessvoid.nifty.input.mouse.MouseInputEvent;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Point;
@ -49,13 +44,16 @@ import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.SwingUtilities;
import com.jme3.input.MouseInput;
import com.jme3.input.RawInputListener;
import com.jme3.input.event.MouseButtonEvent;
import com.jme3.input.event.MouseMotionEvent;
/**
* <code>AwtMouseInput</code>
*

@ -43,8 +43,9 @@ import com.jme3.input.event.MouseButtonEvent;
import com.jme3.input.event.MouseMotionEvent;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.NiftyInputConsumer;
import de.lessvoid.nifty.input.NiftyMouseInputEvent;
import de.lessvoid.nifty.input.keyboard.KeyboardInputEvent;
import de.lessvoid.nifty.input.mouse.MouseInputEvent;
import de.lessvoid.nifty.input.mouse.MouseInputEventQueue;
import de.lessvoid.nifty.spi.input.InputSystem;
import java.util.ArrayList;
@ -100,11 +101,18 @@ public class InputSystemJme implements InputSystem, RawInputListener {
private void onMouseMotionEventQueued(MouseMotionEvent evt, NiftyInputConsumer nic) {
x = evt.getX();
y = height - evt.getY();
MouseInputEvent niftyEvt = new MouseInputEvent(x, y, pressed);
if (nic.processMouseEvent(niftyEvt) /*|| nifty.getCurrentScreen().isMouseOverElement()*/){
MouseInputEventQueue niftyEvtQueue = nifty.getMouseInputEventQueue();
NiftyMouseInputEvent niftyEvt = new NiftyMouseInputEvent();
if (niftyEvtQueue.hasLastMouseDownEvent()) {
niftyEvt = niftyEvtQueue.getLastMouseDownEvent();
}
niftyEvt.initialize(x, y, evt.getDeltaWheel(), niftyEvt.isButton0Down(), niftyEvt.isButton1Down(), niftyEvt.isButton2Down());
niftyEvtQueue.process(niftyEvt);
//MouseInputEvent niftyEvt = new MouseInputEvent(x, y, pressed);
// if (nic.processMouseEvent(niftyEvt) /*|| nifty.getCurrentScreen().isMouseOverElement()*/){
// Do not consume motion events
//evt.setConsumed();
}
// }
}
public void onMouseMotionEvent(MouseMotionEvent evt) {
@ -118,10 +126,19 @@ public class InputSystemJme implements InputSystem, RawInputListener {
private void onMouseButtonEventQueued(MouseButtonEvent evt, NiftyInputConsumer nic) {
pressed = evt.isPressed();
MouseInputEvent niftyEvt = new MouseInputEvent(x, y, pressed);
if (nic.processMouseEvent(niftyEvt) /*|| nifty.getCurrentScreen().isMouseOverElement()*/){
evt.setConsumed();
MouseInputEventQueue niftyEvtQueue = nifty.getMouseInputEventQueue();
NiftyMouseInputEvent niftyEvt = new NiftyMouseInputEvent();
if (niftyEvtQueue.hasLastMouseDownEvent()) {
niftyEvt = niftyEvtQueue.getLastMouseDownEvent();
}
niftyEvt.initialize(x, y, 0, evt.getButtonIndex() == 0 && evt.isPressed(), evt.getButtonIndex() == 1
&& evt.isPressed(), evt.getButtonIndex() == 2 && evt.isPressed());
niftyEvtQueue.process(niftyEvt);
// MouseInputEvent niftyEvt = new MouseInputEvent(x, y, pressed);
// if (nic.processMouseEvent(niftyEvt) /*|| nifty.getCurrentScreen().isMouseOverElement()*/){
evt.setConsumed();
// }
}
public void onMouseButtonEvent(MouseButtonEvent evt) {

Loading…
Cancel
Save