Ejemplo n.º 1
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();
  }
Ejemplo n.º 2
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;
  }