com.jme3.input.event.MouseMotionEvent Java Examples
The following examples show how to use
com.jme3.input.event.MouseMotionEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TerrainCameraController.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void onMouseMotionEvent(MouseMotionEvent mme) { super.onMouseMotionEvent(mme); // if one of the terrain edit buttons is not enabled, return if (!isTerrainEditButtonEnabled()) { return; } // move the marker Vector3f pos = getTerrainCollisionPoint(); if (pos != null) { toolController.doMoveEditTool(pos); } }
Example #2
Source File: InputSystemJme.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
public void forwardEvents(NiftyInputConsumer nic) { int queueSize = inputQueue.size(); for (int i = 0; i < queueSize; i++){ InputEvent evt = inputQueue.get(i); if (evt instanceof MouseMotionEvent){ onMouseMotionEventQueued( (MouseMotionEvent)evt, nic); }else if (evt instanceof MouseButtonEvent){ onMouseButtonEventQueued( (MouseButtonEvent)evt, nic); }else if (evt instanceof KeyInputEvent){ onKeyEventQueued( (KeyInputEvent)evt, nic); } } inputQueue.clear(); }
Example #3
Source File: GlfwMouseInput.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void onCursorPos(final long window, final double xpos, final double ypos) { int xDelta; int yDelta; int x = (int) Math.round(xpos); int y = currentHeight - (int) Math.round(ypos); xDelta = x - mouseX; yDelta = y - mouseY; mouseX = x; mouseY = y; if (xDelta != 0 || yDelta != 0) { final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(x, y, xDelta, yDelta, mouseWheel, 0); mouseMotionEvent.setTime(getInputTimeNanos()); mouseMotionEvents.add(mouseMotionEvent); } }
Example #4
Source File: GlfwMouseInputVR.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void onCursorPos(long window, double xpos, double ypos) { int x = (int) Math.round(xpos); int y = context.getSettings().getHeight() - (int) Math.round(ypos); if (mouseX == 0) { mouseX = x; } if (mouseY == 0) { mouseY = y; } xDelta = x - mouseX; yDelta = y - mouseY; mouseX = x; mouseY = y; if (xDelta != 0 || yDelta != 0) { final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(x, y, xDelta, yDelta, mouseWheel, 0); mouseMotionEvent.setTime(getInputTimeNanos()); mouseMotionEvents.add(mouseMotionEvent); } }
Example #5
Source File: AndroidTouchInput.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void update() { if (listener != null) { InputEvent inputEvent; while ((inputEvent = inputEventQueue.poll()) != null) { if (inputEvent instanceof TouchEvent) { listener.onTouchEvent((TouchEvent)inputEvent); } else if (inputEvent instanceof MouseButtonEvent) { listener.onMouseButtonEvent((MouseButtonEvent)inputEvent); } else if (inputEvent instanceof MouseMotionEvent) { listener.onMouseMotionEvent((MouseMotionEvent)inputEvent); } else if (inputEvent instanceof KeyInputEvent) { listener.onKeyEvent((KeyInputEvent)inputEvent); } } } }
Example #6
Source File: IosInputHandler.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void update() { logger.log(Level.FINE, "InputEvent update : {0}", new Object[]{listener}); if (listener != null) { InputEvent inputEvent; while ((inputEvent = inputEventQueue.poll()) != null) { if (inputEvent instanceof TouchEvent) { listener.onTouchEvent((TouchEvent)inputEvent); } else if (inputEvent instanceof MouseButtonEvent) { listener.onMouseButtonEvent((MouseButtonEvent)inputEvent); } else if (inputEvent instanceof MouseMotionEvent) { listener.onMouseMotionEvent((MouseMotionEvent)inputEvent); } else if (inputEvent instanceof KeyInputEvent) { listener.onKeyEvent((KeyInputEvent)inputEvent); } } } }
Example #7
Source File: Button.java From Lemur with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void mouseEntered( MouseMotionEvent event, Spatial target, Spatial capture ) { if( !isEnabled() ) return; if( capture == Button.this || (target == Button.this && capture == null) ) { showHighlight(true); commandMap.runCommands(ButtonAction.HighlightOn); runEffect(EFFECT_ACTIVATE); } }
Example #8
Source File: InputManager.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * Callback from RawInputListener. Do not use. */ public void onMouseMotionEvent(MouseMotionEvent evt) { if (!eventsPermitted) { throw new UnsupportedOperationException("MouseInput has raised an event at an illegal time."); } cursorPos.set(evt.getX(), evt.getY()); inputQueue.add(evt); }
Example #9
Source File: TestSoftwareMouse.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void onMouseMotionEvent(MouseMotionEvent evt) { x += evt.getDX(); y += evt.getDY(); // Prevent mouse from leaving screen AppSettings settings = TestSoftwareMouse.this.settings; x = FastMath.clamp(x, 0, settings.getWidth()); y = FastMath.clamp(y, 0, settings.getHeight()); // adjust for hotspot cursor.setPosition(x, y - 64); }
Example #10
Source File: AwtMouseInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void update() { if (cursorMoved){ int newX = location.x; int newY = location.y; int newWheel = wheelPos; // invert DY int actualX = lastKnownLocation.x; int actualY = component.getHeight() - lastKnownLocation.y; MouseMotionEvent evt = new MouseMotionEvent(actualX, actualY, newX - lastEventX, lastEventY - newY, wheelPos, lastEventWheel - wheelPos); listener.onMouseMotionEvent(evt); lastEventX = newX; lastEventY = newY; lastEventWheel = newWheel; cursorMoved = false; } synchronized (eventQueue){ eventQueueCopy.clear(); eventQueueCopy.addAll(eventQueue); eventQueue.clear(); } int size = eventQueueCopy.size(); for (int i = 0; i < size; i++){ listener.onMouseButtonEvent(eventQueueCopy.get(i)); } }
Example #11
Source File: InputSystemJme.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void onMouseMotionEvent(MouseMotionEvent evt) { // Only forward the event if there's actual motion involved. if (inputManager.isCursorVisible() && (evt.getDX() != 0 || evt.getDY() != 0 || evt.getDeltaWheel() != 0)){ inputQueue.add(evt); } }
Example #12
Source File: InputSystemJme.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private void onMouseMotionEventQueued(MouseMotionEvent evt, NiftyInputConsumer nic) { x = evt.getX(); y = height - evt.getY(); nic.processMouseEvent(x, y, evt.getDeltaWheel(), buttonIndex, pressed); // if (nic.processMouseEvent(niftyEvt) /*|| nifty.getCurrentScreen().isMouseOverElement()*/){ // Do not consume motion events //evt.setConsumed(); // } }
Example #13
Source File: GlfwMouseInputVR.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void onWheelScroll(long window, double xOffset, double yOffset) { mouseWheel += yOffset; final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(mouseX, mouseY, 0, 0, mouseWheel, (int) Math.round(yOffset)); mouseMotionEvent.setTime(getInputTimeNanos()); mouseMotionEvents.add(mouseMotionEvent); }
Example #14
Source File: AWTMouseInput.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void onCursorPos(double xpos, double ypos) { int xDelta; int yDelta; int x = (int) Math.round(xpos); int y = context.getHeight() - (int) Math.round(ypos); if (mouseX == 0) mouseX = x; if (mouseY == 0) mouseY = y; xDelta = x - mouseX; yDelta = y - mouseY; mouseX = x; mouseY = y; if (xDelta == 0 && yDelta == 0) return; final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(x, y, xDelta, yDelta, mouseWheel, 0); mouseMotionEvent.setTime(getInputTimeNanos()); EXECUTOR.addToExecute(new Runnable() { @Override public void run() { mouseMotionEvents.add(mouseMotionEvent); } }); }
Example #15
Source File: AwtMouseInput.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void update() { if (cursorMoved) { int newX = location.x; int newY = location.y; int newWheel = wheelPos; // invert actual Y and DY for motion events int actualX = lastKnownLocation.x; int actualY = component.getHeight() - lastKnownLocation.y; MouseMotionEvent evt = new MouseMotionEvent(actualX, actualY, newX - lastEventX, lastEventY - newY, wheelPos, lastEventWheel - wheelPos); listener.onMouseMotionEvent(evt); lastEventX = newX; lastEventY = newY; lastEventWheel = newWheel; cursorMoved = false; } synchronized (eventQueue) { eventQueueCopy.clear(); eventQueueCopy.addAll(eventQueue); eventQueue.clear(); } int size = eventQueueCopy.size(); for (int i = 0; i < size; i++) { listener.onMouseButtonEvent(eventQueueCopy.get(i)); } }
Example #16
Source File: Button.java From Lemur with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void mouseExited( MouseMotionEvent event, Spatial target, Spatial capture ) { //if( !isEnabled() ) // return; if( !isHighlightOn() ) { // If the highlight is on then we need to run through // the events regardless of enabled state... and if it's // not on then there is no reason to run events. } showHighlight(false); commandMap.runCommands(ButtonAction.HighlightOff); runEffect(EFFECT_DEACTIVATE); }
Example #17
Source File: TestJoystick.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void onMouseMotionEvent(MouseMotionEvent evt) {}
Example #18
Source File: AWTMouseInput.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void onWheelScroll(final double xOffset, final double yOffset) { mouseWheel += yOffset; final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(mouseX, mouseY, 0, 0, mouseWheel, (int) Math.round(yOffset)); mouseMotionEvent.setTime(getInputTimeNanos()); EXECUTOR.addToExecute(new Runnable() { @Override public void run() { mouseMotionEvents.add(mouseMotionEvent); } }); }
Example #19
Source File: GlfwMouseInput.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void onWheelScroll(final long window, final double xOffset, final double yOffset) { mouseWheel += yOffset; final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(mouseX, mouseY, 0, 0, mouseWheel, (int) Math.round(yOffset)); mouseMotionEvent.setTime(getInputTimeNanos()); mouseMotionEvents.add(mouseMotionEvent); }
Example #20
Source File: AWTMouseInput.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
public AWTMouseInput(AWTContext context) { super(context); mouseMotionEvents = new LinkedList<MouseMotionEvent>(); mouseButtonEvents = new LinkedList<MouseButtonEvent>(); }
Example #21
Source File: MouseAppState.java From Lemur with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void onMouseMotionEvent( MouseMotionEvent evt ) { //if( isEnabled() ) // dispatch(evt); scrollWheel = evt.getWheel(); }
Example #22
Source File: DefaultRawInputListener.java From Lemur with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void onMouseMotionEvent( MouseMotionEvent evt ) { }
Example #23
Source File: Button.java From Lemur with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void mouseMoved( MouseMotionEvent event, Spatial target, Spatial capture ) { //System.out.println("mouseMoved(" + event + ")"); commandMap.runCommands(ButtonAction.Hover); }
Example #24
Source File: TestBitmapFont.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void onMouseMotionEvent(MouseMotionEvent evt) { }
Example #25
Source File: SelectionState.java From Lemur with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void onMouseMotionEvent( MouseMotionEvent evt ) { //if( isEnabled() ) // dispatch(evt); }
Example #26
Source File: AbstractCameraController.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void onMouseMotionEvent(MouseMotionEvent mme) { mouseX = mme.getX(); mouseY = mme.getY(); }
Example #27
Source File: RawInputListener.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 2 votes |
/** * Invoked on mouse movement/motion events. * * @param evt */ public void onMouseMotionEvent(MouseMotionEvent evt);