Java Code Examples for java.awt.event.MouseEvent.isMetaDown()

The following are Jave code examples for showing how to use isMetaDown() of the java.awt.event.MouseEvent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: VASSAL-src   File: PropertySheet.java   View Source Code Vote up 6 votes
public void mouseClicked(MouseEvent event) {

      if ((event.isMetaDown() || event.isShiftDown()) && panelType != TICKS_VALMAX) {
        new EditTickLabelValueDialog(this);
        return;
      }
      int col = Math.min((event.getX() - leftMargin + 1) / dx, numCols - 1);
      int row = Math.min((event.getY() - topMargin + 1) / dx, numRows - 1);
      int num = row * numCols + col + 1;

      // Checkbox behavior; toggle the box clicked on
      // numTicks = num > numTicks ? num : num - 1;

      // Slider behavior; set the box clicked on and all to left and clear all boxes to right,
      // UNLESS user clicked on last set box (which would do nothing), in this case, toggle the
      // box clicked on.  This is the only way the user can clear the first box.

      numTicks = (num == numTicks) ? num - 1 : num;
      fireActionEvent();

      repaint();
    }
 
Example 2
Project: VASSAL-src   File: RegionGrid.java   View Source Code Vote up 6 votes
public void mouseClicked(MouseEvent e) {
  final Point p = e.getPoint();
  lastClick = p;

  if (e.isMetaDown()) { // Right click...menu
    doPopupMenu(e);
  }
  else if (lastClickedRegion != null) {

    if (e.getClickCount() >= 2) { // Double click show properties
      if (lastClickedRegion.getConfigurer() != null) {
        final Action a =
          new EditPropertiesAction(lastClickedRegion, null, this);
        if (a != null) {
          a.actionPerformed(
              new ActionEvent(
                  e.getSource(),
                  ActionEvent.ACTION_PERFORMED,
                  "Edit")); //$NON-NLS-1$
        }
      }
    }

  }
  view.repaint(); // Clean up selection
}
 
Example 3
Project: VASSAL-src   File: RegionGrid.java   View Source Code Vote up 6 votes
public void mouseDragged(MouseEvent e) {
  if (!e.isMetaDown()) {
    scrollAtEdge(e.getPoint(), 15);
  }

  if (selectionRect != null) {
    // FIXME: inefficient, could be done with only one new Rectangle
    final Rectangle repaintRect =
      new Rectangle(selectionRect.x-1, selectionRect.y-1,
                    selectionRect.width+3, selectionRect.height+3);

    selectionRect.x = Math.min(e.getX(), anchor.x);
    selectionRect.y = Math.min(e.getY(), anchor.y);
    selectionRect.width = Math.abs(e.getX() - anchor.x);
    selectionRect.height = Math.abs(e.getY() - anchor.y);

    repaintRect.add(
      new Rectangle(selectionRect.x-1, selectionRect.y-1,
                    selectionRect.width+3, selectionRect.height+3));
    view.repaint(repaintRect);
  }
}
 
Example 4
Project: VASSAL-src   File: PolygonEditor.java   View Source Code Vote up 6 votes
public void mousePressed(MouseEvent e) {
  selected = -1;
  double minDist = Float.MAX_VALUE;
  for (int i = 0; i < polygon.npoints; ++i) {
    double dist = Point2D.distance(polygon.xpoints[i], polygon.ypoints[i], e.getX(), e.getY());
    if (dist < minDist) {
      minDist = dist;
      selected = i;
    }
  }
  if (e.isMetaDown()) {
    polygon.addPoint(e.getX(), e.getY());
    if (selected >= 0) {
      for (int i = polygon.npoints - 1; i > selected; --i) {
        polygon.xpoints[i] = polygon.xpoints[i - 1];
        polygon.ypoints[i] = polygon.ypoints[i - 1];
      }
      polygon.xpoints[selected] = e.getX();
      polygon.ypoints[selected] = e.getY();
    }
  }
}
 
Example 5
Project: VASSAL-src   File: MapCenterer.java   View Source Code Vote up 6 votes
public void mouseReleased(MouseEvent e) {
  if (e.isMetaDown()) {
    GamePiece found = map.findPiece(e.getPoint(), finder);
    if (found != null) {
      EventFilter filter = (EventFilter) found.getProperty(Properties.SELECT_EVENT_FILTER);
      if (filter != null
          && filter.rejectEvent(e)) {
        found = null;
      }
    }
    if (found == null) {
      Map.View m = (Map.View) e.getSource();
      m.getMap().centerAt(e.getPoint());
    }
  }
}
 
Example 6
Project: VASSAL-src   File: HtmlChart.java   View Source Code Vote up 6 votes
public void mousePressed(MouseEvent event) {
  if (event.isMetaDown()) {
    final JPopupMenu popup = new JPopupMenu();
    final JMenuItem item = new JMenuItem("Return to default page");

    item.addActionListener(new ActionListener() {
      // Return to default page
      public void actionPerformed(ActionEvent e) {
        setFile(fileName);
      }
    });

    popup.add(item);
    if (event.getComponent().isShowing()) {
      popup.show(event.getComponent(), event.getX(), event.getY());
    }
  }
}
 
Example 7
Project: jmonet   File: MagnifierTool.java   View Source Code Vote up 6 votes
/** {@inheritDoc} */
@Override
public void mousePressed(MouseEvent e, Point imageLocation) {

    double pX = (double) imageLocation.x / (double) getCanvas().getCanvasImage().getWidth();
    double pY = (double) imageLocation.y / (double) getCanvas().getCanvasImage().getHeight();

    if (e.isControlDown() || e.isAltDown() || e.isMetaDown()) {
        reset();
    }

    else if (e.isShiftDown()) {
        zoomOut(e.getX(), e.getY());
        getCanvas().setScrollPosition(pX, pY);
    }

    else {
        zoomIn();
        getCanvas().setScrollPosition(pX, pY);
    }
}
 
Example 8
Project: LivroJavaComoProgramar10Edicao   File: MouseDetailsFrame.java   View Source Code Vote up 6 votes
@Override
public void mouseClicked(MouseEvent event)
{
   int xPos = event.getX(); // get x-position of mouse
   int yPos = event.getY(); // get y-position of mouse

   details = String.format("Clicked %d time(s)", 
      event.getClickCount());

   if (event.isMetaDown()) // right mouse button   
      details += " with right mouse button";
   else if (event.isAltDown()) // middle mouse button
      details += " with center mouse button";
   else // left mouse button                       
      details += " with left mouse button";

   statusBar.setText(details); 
}
 
Example 9
Project: marathonv5   File: RComponent.java   View Source Code Vote up 5 votes
protected void mousePressed(MouseEvent me) {
    if (me.getButton() == MouseEvent.BUTTON1 && me.getClickCount() == 1 && !me.isAltDown() && !me.isMetaDown()
            && !me.isAltGraphDown() && !me.isControlDown()) {
        mouseButton1Pressed(me);
    } else {
        recorder.recordClick2(this, me, true);
    }
}
 
Example 10
Project: VASSAL-src   File: PieceMover.java   View Source Code Vote up 5 votes
protected boolean canHandleEvent(MouseEvent e) {
  return !e.isShiftDown() &&
         !e.isControlDown() &&
         !e.isMetaDown() &&
          e.getClickCount() < 2 &&
         !e.isConsumed();
}
 
Example 11
Project: VASSAL-src   File: Map.java   View Source Code Vote up 5 votes
/**
 * Mouse motion events are not forwarded to LocalMouseListeners or to
 * listeners on the stack.
 *
 * The map scrolls when dragging the mouse near the edge.
 */
public void mouseDragged(MouseEvent e) {
  if (!e.isMetaDown()) {
    scrollAtEdge(e.getPoint(), SCROLL_ZONE);
  }
  else {
    if (scroller.isRunning()) scroller.stop();
  }
}
 
Example 12
Project: TrabalhoFinalEDA2   File: mxGraphComponent.java   View Source Code Vote up 5 votes
/**
 * 
 * @param event
 * @return Returns true if the given event should toggle selected cells.
 */
public boolean isToggleEvent(MouseEvent event)
{
	// NOTE: IsMetaDown always returns true for right-clicks on the Mac, so
	// toggle selection for left mouse buttons requires CMD key to be pressed,
	// but toggle for right mouse buttons requires CTRL to be pressed.
	return (event != null) ? ((mxUtils.IS_MAC) ? ((SwingUtilities
			.isLeftMouseButton(event) && event.isMetaDown()) || (SwingUtilities
			.isRightMouseButton(event) && event.isControlDown()))
			: event.isControlDown())
			: false;
}
 
Example 13
Project: Tarski   File: mxGraphComponent.java   View Source Code Vote up 5 votes
/**
 * 
 * @param event
 * @return Returns true if the given event should toggle selected cells.
 */
public boolean isToggleEvent(MouseEvent event) {
  // NOTE: IsMetaDown always returns true for right-clicks on the Mac, so
  // toggle selection for left mouse buttons requires CMD key to be pressed,
  // but toggle for right mouse buttons requires CTRL to be pressed.
  return (event != null) ? ((mxUtils.IS_MAC)
      ? ((SwingUtilities.isLeftMouseButton(event) && event.isMetaDown())
          || (SwingUtilities.isRightMouseButton(event) && event.isControlDown()))
      : event.isControlDown()) : false;
}
 
Example 14
Project: incubator-netbeans   File: ProfilerTableContainer.java   View Source Code Vote up 4 votes
private static boolean onlyShift(MouseEvent e) {
    return e.isShiftDown() && !(e.isAltDown() || e.isAltGraphDown() ||
                                e.isControlDown() || e.isMetaDown());
}
 
Example 15
Project: incubator-netbeans   File: JTreeTablePanel.java   View Source Code Vote up 4 votes
private static boolean onlyShift(MouseEvent e) {
    return e.isShiftDown() && !(e.isAltDown() || e.isAltGraphDown() ||
                                e.isControlDown() || e.isMetaDown());
}
 
Example 16
Project: VASSAL-src   File: TurnTracker.java   View Source Code Vote up 4 votes
public void mouseClicked(MouseEvent e) {
  if (e.isMetaDown()) {
    doPopup(e.getPoint());
  }
}
 
Example 17
Project: myster   File: MCListEventHandler.java   View Source Code Vote up 4 votes
public void mousePressed(MouseEvent e) {
    callback.requestFocus(); //Fucking bug n Java me thinks.
    long currenttime = System.currentTimeMillis();
    int workingselection = -1;
    workingselection = callback.getClicked(e.getX(), e.getY());

    if (e.isShiftDown() && firstselect != -1 && !callback.isSingleSelect()) {
        int sign = getSign(firstselect - workingselection);
        for (int i = firstselect; i != (workingselection - sign); i = i - sign) {
            callback.select(i);
        }
        if (firstselect != (workingselection - sign))
            selectItemEventDispatch();
        callback.repaint();
    } else if (e.isMetaDown() && firstselect != -1 && !callback.isSingleSelect()) {
        if (workingselection != -1)
            callback.toggle(workingselection);
        if (callback.isSelected(workingselection))
            selectItemEventDispatch();
        else
            unselectItemEventDispatch();
        callback.repaint();
    } else {
        //doubleclick Check
        if (currenttime - clickedtime < DCTIME && (!doubleclickflag)
                && callback.isSelected(workingselection))
            doubleclickflag = true;
        else {
            clickedtime = System.currentTimeMillis();
            doubleclickflag = false;
        }

        if (!callback.isSelected(workingselection) || workingselection == -1) {
            firstselect = workingselection;
            callback.clearAllSelected();
            unselectItemEventDispatch();
            callback.select(workingselection);
            selectItemEventDispatch();
            callback.repaint();
        }
    }

    if (e.isMetaDown() && !callback.isSingleSelect()) {
        if (callback.isSelected(workingselection) && workingselection != -1)
            select = true;
        else
            select = false;
    }

}
 
Example 18
Project: rapidminer   File: SwingTools.java   View Source Code Vote up 3 votes
/**
 * Returns whether or not the control modifier is down during the event. This takes the OS into
 * account, so on Mac it will check if the meta modifier is down during the event.
 *
 * @param e
 *            the event
 * @return {@code true} if the control modifier is down on Windows/Linux or the meta modifier is
 *         down on Mac; {@code false} otherwise
 */
public static boolean isControlOrMetaDown(MouseEvent e) {
	if (!IS_MAC) {
		return e.isControlDown();
	} else {
		return e.isMetaDown();
	}
}