Пример #1
0
  public void mouseReleased(MouseEvent e) {
    synchronized (futureData) {
      // This might be the end of a drag
      if (isDragging) {
        // In case we already have a dragEnded and we get another
        // dragEnded, should use the new one
        if (futureData.isMouseDragEnded(null)) {
          futureData = potentialNewDragData;
        }

        if (!PriorityManager.isHigherPriority(e, futureData)) return;
        registerEventRecieved();
        int x = locator.getTranslatedX(e);
        int y = locator.getTranslatedY(e);
        int button = getButton(e);

        Actor clickActor = locator.getTopMostActorAt(e);
        futureData.mouseClicked(x, y, button, 1, clickActor);

        Actor actor = dragStartData.getActor();
        futureData.mouseDragEnded(x, y, button, actor);
        isDragging = false;
        potentialNewDragData = new MouseEventData();
      }
    }
  }
Пример #2
0
  public void mouseDragged(MouseEvent e) {
    synchronized (futureData) {
      isDragging = true;

      if (!PriorityManager.isHigherPriority(e, futureData)) return;
      registerEventRecieved();

      // Find and store the actor that relates to this drag.
      int x = locator.getTranslatedX(e);
      int y = locator.getTranslatedY(e);
      int button = getButton(e);
      futureData.mouseDragged(x, y, button, dragStartData.getActor());
    }
  }
Пример #3
0
  public void mouseClicked(MouseEvent e) {
    synchronized (futureData) {
      MouseEventData mouseData = futureData;
      // In case we already have a dragEnded and we get another
      // dragEnded, we need to start collection data for that.
      if (futureData.isMouseDragEnded(null)) {
        mouseData = potentialNewDragData;
      }
      if (!PriorityManager.isHigherPriority(e, mouseData)) return;
      registerEventRecieved();
      Actor actor = locator.getTopMostActorAt(e);
      int x = locator.getTranslatedX(e);
      int y = locator.getTranslatedY(e);
      int button = getButton(e);

      mouseData.mouseClicked(x, y, button, e.getClickCount(), actor);
      isDragging = false;
    }
  }
Пример #4
0
 public void mouseMoved(MouseEvent e) {
   synchronized (futureData) {
     if (!PriorityManager.isHigherPriority(e, futureData)) return;
     registerEventRecieved();
     Actor actor = locator.getTopMostActorAt(e);
     int x = locator.getTranslatedX(e);
     int y = locator.getTranslatedY(e);
     int button = getButton(e);
     futureData.mouseMoved(x, y, button, actor);
     isDragging = false;
   }
 }
Пример #5
0
  public void mousePressed(MouseEvent e) {
    synchronized (futureData) {
      MouseEventData mouseData = futureData;
      // In case we already have a dragEnded and we get another
      // dragEnded, we need to start collection data for that.
      if (futureData.isMouseDragEnded(null)) {
        mouseData = potentialNewDragData;
      }

      // This might be the beginning of a drag so we store it
      dragStartData = new MouseEventData();
      Actor actor = locator.getTopMostActorAt(e);
      int x = locator.getTranslatedX(e);
      int y = locator.getTranslatedY(e);
      int button = getButton(e);
      dragStartData.mousePressed(x, y, button, actor);

      // We only really want to register this event as a press if there is no higher priorities
      if (!PriorityManager.isHigherPriority(e, mouseData)) return;
      registerEventRecieved();
      mouseData.mousePressed(x, y, button, actor);
      isDragging = false;
    }
  }
Пример #6
0
 /**
  * Gets the mouse info with information about the current state of the mouse. Within the same
  * act-loop it will always return exactly the same MouseInfo object with exactly the same
  * contents.
  *
  * @return The info about the current state of the mouse. Null if nothing mouse related has
  *     happened in this act round.
  */
 public MouseInfo getMouseInfo() {
   freezeMouseData();
   return currentData.getMouseInfo();
 }
Пример #7
0
 /**
  * Whether the mouse had been moved on the given object. The mouse is considered to be moved on an
  * object, only if the mouse pointer is above that object.
  *
  * <p>If the parameter is an Actor the method will only return true if the move is on the given
  * actor - if there are several actors at the same place, only the top most actor will count. If
  * the parameter is a World then true will be returned only if the move is outside the boundaries
  * of all Actors. If the parameter is null, then it will return true no matter where the drag was
  * started as long as it is inside the world boundaries.
  *
  * @param obj Typically one of Actor, World or null
  * @return True if the mouse has been moved as explained above
  */
 public boolean isMouseMoved(Object obj) {
   freezeMouseData();
   return currentData.isMouseMoved(obj);
 }