@Override public boolean mouseClicked(final MouseButton button, final InputState state) { final int mouseX = state.getMouseState().getX(), mouseY = state.getMouseState().getY(); final UIComponent over = getUIComponent(mouseX, mouseY); if (over == _titleLabel || over == this) { _drawer.toggleExpanded(); } return true; } }
if (_currentMouseState.getDwheel() == 0 && _currentMouseState.getDx() == 0 && _currentMouseState.getDy() == 0) { _currentMouseState = new MouseState(_currentMouseState.getX(), _currentMouseState.getY(), 0, 0, 0, _currentMouseState.getButtonStates(), _currentMouseState.getClickCounts());
if (current.getButtonState(_dragButton) != ButtonState.DOWN) { if (_dragging) { endDrag(manager); else if (!current.getButtonsPressedSince(previous).contains(_dragButton) && !_dragging) { return false; final Vector2 oldMouse = new Vector2(previous.getX(), previous.getY()); if (current == previous || current.getDx() == 0 && current.getDy() == 0) { return false;
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final MouseState mouse = inputStates.getCurrent().getMouseState(); if (mouse.getDx() != 0 || mouse.getDy() != 0) { if (!firstPing) { move(_xSpeed * mouse.getDx(), _ySpeed * mouse.getDy()); } else { firstPing = false; } } if (mouse.getDwheel() != 0) { zoom(_zoomSpeed * mouse.getDwheel()); } } };
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final MouseState mouse = inputStates.getCurrent().getMouseState(); if (mouse.getDx() != 0 || mouse.getDy() != 0) { if (!firstPing) { FirstPersonControl.this.rotate(source.getCanvasRenderer().getCamera(), -mouse.getDx(), -mouse.getDy()); } else { firstPing = false; } } } };
@Override public void invoke(final long window, final double xoffset, final double yoffset) { wheelAccum += yoffset; final int dw = (int) MathUtils.floor(wheelAccum); if (dw == 0) { return; } wheelAccum -= dw; // Add our new state final int x = _lastState != null ? _lastState.getX() : 0; final int y = _lastState != null ? _lastState.getY() : 0; final MouseState event = new MouseState(x, y, 0, 0, dw, Maps.newEnumMap(_lastButtonState), null); addNextState(event); } });
if (currentMState.hasButtonState(ButtonState.DOWN)) { final EnumSet<MouseButton> pressed = currentMState.getButtonsPressedSince(previousMState); if (!pressed.isEmpty()) { for (final MouseButton button : pressed) { if (previousMState.hasButtonState(ButtonState.DOWN)) { final EnumSet<MouseButton> released = currentMState.getButtonsReleasedSince(previousMState); if (!released.isEmpty()) { for (final MouseButton button : released) { if (currentMState.getDx() != 0 || currentMState.getDy() != 0) { consumed |= fireMouseMoved(currentMState.getX(), currentMState.getY(), current); if (currentMState.getDwheel() != 0) { consumed |= fireMouseWheelMoved(currentMState.getDwheel(), current);
final MouseState nextState = new MouseState(Mouse.getEventX(), Mouse.getEventY(), Mouse.getEventDX(), Mouse .getEventDY(), Mouse.getEventDWheel(), buttons, null); if (nextState.getDx() != 0.0 || nextState.getDy() != 0.0) { _clickArmed.clear(); _clicks.clear(); _nextState = nextState; _sendClickState = false; return new MouseState(nextState.getX(), nextState.getY(), nextState.getDx(), nextState.getDy(), nextState.getDwheel(), buttons, EnumMultiset.create(_clicks)); } else { return nextState;
assertEquals("x", 0, s1.getX()); assertEquals("dx", 0, s1.getDx()); assertEquals("y", 100, s1.getY()); assertEquals("dy", 0, s1.getDy()); assertTrue("left down", s1.getButtonState(MouseButton.LEFT) == ButtonState.DOWN); assertFalse("right down", s1.getButtonState(MouseButton.RIGHT) == ButtonState.DOWN); assertEquals("x", 2, s2.getX()); assertEquals("dx", 2, s2.getDx()); assertEquals("y", 96, s2.getY()); assertEquals("dy", -4, s2.getDy()); assertTrue("left down", s2.getButtonState(MouseButton.LEFT) == ButtonState.DOWN); assertFalse("right down", s2.getButtonState(MouseButton.RIGHT) == ButtonState.DOWN); assertEquals("x", 2, s1.getX()); assertEquals("dx", 0, s1.getDx()); assertEquals("y", 96, s1.getY()); assertEquals("dy", 0, s1.getDy()); assertTrue("left down", s1.getButtonState(MouseButton.LEFT) == ButtonState.DOWN); assertTrue("right down", s1.getButtonState(MouseButton.RIGHT) == ButtonState.DOWN); assertTrue("clicked", s1.getClickCount(MouseButton.LEFT) == 0); assertEquals("x", 3, s1.getX()); assertEquals("dx", 1, s1.getDx()); assertEquals("y", 95, s1.getY()); assertEquals("dy", -1, s1.getDy()); assertFalse("left down", s1.getButtonState(MouseButton.LEFT) == ButtonState.DOWN); assertTrue("right down", s1.getButtonState(MouseButton.RIGHT) == ButtonState.DOWN);
if (mouseState.getButtonsPressedSince(previousState.getMouseState()).contains(_button)) { _armed = true; _armedX = mouseState.getX(); _armedY = mouseState.getY(); _armedAt = now; if (mouseState.getButtonsPressedSince(previousState.getMouseState()).size() > 0) { _armed = false; return false; final float dx = _armedX - mouseState.getX(); final float dy = _armedY - mouseState.getY(); if (mouseState.getButtonState(_button) != ButtonState.DOWN || MathUtils.sqrt(dx * dx + dy * dy) > _maxDrift) { _armed = false; return false;
private void initState(final MouseEvent mouseEvent) { if (_lastState == null) { _lastState = new MouseState(mouseEvent.getX(), getArdor3DY(mouseEvent), 0, 0, 0, null, null); } }
final Camera camera = source.getCanvasRenderer().getCamera(); if (current.getButtonState(_dragButton) != ButtonState.DOWN) { if (_lastInputWidget != null) { _lastInputWidget.processInput(source, inputStates, inputConsumed, manager); final Vector2 oldMouse = new Vector2(previous.getX(), previous.getY()); findPick(oldMouse, camera); if (_results.getNumber() <= 0) {
@Override public void processInput(final Canvas source, final TwoInputStates inputStates, final AtomicBoolean inputConsumed, final InteractManager manager) { final Camera camera = source.getCanvasRenderer().getCamera(); final MouseState current = inputStates.getCurrent().getMouseState(); final MouseState previous = inputStates.getPrevious().getMouseState(); // first process mouse over state checkMouseOver(source, current, manager); if (current.getButtonsReleasedSince(previous).contains(_dragButton)) { _rotateStore.setIdentity(); if (_interactMatrix != InteractMatrix.Local) { setRingRotations(Matrix3.IDENTITY); } } // Now check drag status if (!checkShouldDrag(camera, current, previous, inputConsumed, manager)) { return; } // act on drag if (_lastDragSpatial instanceof InteractRing) { _lastRing = (InteractRing) _lastDragSpatial; final Vector2 oldMouse = new Vector2(previous.getX(), previous.getY()); final ReadOnlyQuaternion rot = getNewAxisRotation(_lastRing, oldMouse, current, camera, manager); final Transform transform = manager.getSpatialState().getTransform(); rot.toRotationMatrix(_calcMat3).multiply(transform.getMatrix(), _calcMat3); transform.setRotation(_calcMat3); // apply our filters, if any, now that we've made updates. applyFilters(manager); } }
/** * Returns all the buttons' states. It could be easier for most classes to use the * {@link #getButtonState(MouseButton)} methods, and that also results in less object creation. * * @return a defensive copy of the states of all the buttons at this point in time. */ public EnumMap<MouseButton, ButtonState> getButtonStates() { return getButtonStates(null); }
private int getDX(final MouseEvent e) { return e.x - _lastState.getX(); }
private int getDY(final MouseEvent e) { return getArdor3DY(e) - _lastState.getY(); }
public EnumSet<MouseButton> getButtonsReleasedSince(final MouseState previous) { final EnumSet<MouseButton> result = EnumSet.noneOf(MouseButton.class); for (final MouseButton button : MouseButton.values()) { if (previous.getButtonState(button) == ButtonState.DOWN) { if (getButtonState(button) != ButtonState.DOWN) { result.add(button); } } } return result; }
public boolean apply(final TwoInputStates states) { final InputState currentState = states.getCurrent(); final InputState previousState = states.getPrevious(); if (currentState == null || previousState == null || !previousState.getMouseState().hasButtonState(ButtonState.DOWN)) { return false; } return currentState.getMouseState().getButtonsReleasedSince(previousState.getMouseState()).contains(_button); } }
public boolean apply(final TwoInputStates states) { final InputState currentState = states.getCurrent(); final InputState previousState = states.getPrevious(); if (currentState == null || previousState == null || !currentState.getMouseState().hasButtonState(ButtonState.DOWN)) { return false; } return currentState.getMouseState().getButtonsPressedSince(previousState.getMouseState()).contains(_button); } }