コード例 #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 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;
    }
  }
コード例 #3
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;
    }
  }
コード例 #4
0
 /**
  * A mouse drag has ended. This happens when the mouse has been dragged and the mouse button
  * released.
  *
  * <p>If the parameter is an Actor the method will only return true if the drag started 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 drag was started
  * 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 pressed as explained above
  */
 public boolean isMouseDragEnded(Object obj) {
   freezeMouseData();
   return currentData.isMouseDragEnded(obj);
 }