All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.lessvoid.nifty.slick2d.input.events.MouseEventWheelMoved Maven / Gradle / Ivy

There is a newer version: 1.4.3
Show newest version
package de.lessvoid.nifty.slick2d.input.events;

import de.lessvoid.nifty.NiftyInputConsumer;
import org.newdawn.slick.InputListener;

import javax.annotation.Nonnull;

/**
 * This mouse event is used to store the event generated in case the mouse wheel got moved.
 *
 * @author Martin Karing <[email protected]>
 */
public final class MouseEventWheelMoved extends AbstractMouseEvent {
  /**
   * The delta value that defines how much and into what direction the mouse wheel got moved.
   */
  private final int wheelDelta;

  /**
   * Create a new mouse wheel event and store the delta value.
   *
   * @param x     the x coordinate
   * @param y     the y coordinate
   * @param delta the delta of the mouse wheel movement
   */
  public MouseEventWheelMoved(final int x, final int y, final int delta) {
    super(x, y);
    wheelDelta = delta;
  }

  /**
   * Send the event to a Nifty input consumer.
   */
  @Override
  public boolean sendToNifty(@Nonnull final NiftyInputConsumer consumer) {
    return consumer.processMouseEvent(getX(), getY(), wheelDelta, -1, false);
  }

  /**
   * Send the event to a Slick input listener.
   */
  @Override
  public boolean sendToSlick(@Nonnull final InputListener listener) {
    if(!listener.isAcceptingInput()) return false;
    
    listener.mouseWheelMoved(wheelDelta);
    return true;
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy