Пример #1
0
  @Override
  protected boolean handleEvent(Event evt) {
    if (evt.isMouseEventNoWheel()) {
      if (dragActive) {
        if (evt.isMouseDragEnd()) {
          if (listener != null) {
            listener.dragStopped(this, evt);
          }
          dragActive = false;
          getAnimationState().setAnimationState(STATE_DRAG_ACTIVE, false);
        } else if (listener != null) {
          listener.dragging(this, evt);
        }
      } else if (evt.isMouseDragEvent()) {
        dragActive = true;
        getAnimationState().setAnimationState(STATE_DRAG_ACTIVE, true);
        if (listener != null) {
          listener.dragStarted(this, evt);
        }
      }
      return true;
    }

    return super.handleEvent(evt);
  }
Пример #2
0
  @Override
  protected boolean handleEvent(Event evt) {
    super.handleEvent(evt);
    switch (evt.getType()) {
      case MOUSE_WHEEL:
        // mouse_wheel = evt.getMouseWheelDelta();
        if (evt.getMouseWheelDelta() > 0) fireActionEvent("mouseup");
        else if (evt.getMouseWheelDelta() < 0) fireActionEvent("mousedown");
      default:
        System.out.println("Unhandled Event:" + evt.getType() + evt.getType().name());
    }

    // eat all mouse events
    return evt.isMouseEvent();
  }
Пример #3
0
  @Override
  protected boolean handleEvent(Event evt) {
    if (super.handleEvent(evt)) {
      return true;
    }

    if (state != null) {
      switch (evt.getType()) {
        case KEY_PRESSED:
          state.keyPressed(evt.getKeyCode(), evt.getKeyChar());
          break;
        case KEY_RELEASED:
          state.keyReleased(evt.getKeyCode(), evt.getKeyChar());
          break;
        case MOUSE_BTNDOWN:
          state.mousePressed(evt.getMouseButton(), evt.getMouseX(), evt.getMouseY());
          break;
        case MOUSE_BTNUP:
          state.mouseReleased(evt.getMouseButton(), evt.getMouseX(), evt.getMouseY());
          break;
        case MOUSE_CLICKED:
          state.mouseClicked(
              evt.getMouseButton(), evt.getMouseX(), evt.getMouseY(), evt.getMouseClickCount());
          break;
        case MOUSE_ENTERED:
        case MOUSE_MOVED:
          state.mouseMoved(oldMouseX, oldMouseY, evt.getMouseX(), evt.getMouseY());
          break;
        case MOUSE_DRAGGED:
          state.mouseDragged(oldMouseX, oldMouseY, evt.getMouseX(), evt.getMouseY());
          break;
        case MOUSE_WHEEL:
          state.mouseWheelMoved(evt.getMouseWheelDelta());
          break;
        default:
          break;
      }
    }

    if (evt.isMouseEvent()) {
      oldMouseX = evt.getMouseX();
      oldMouseY = evt.getMouseY();
    }
    return true;
  }