java.awt.event.MouseEvent#isMetaDown()源码实例Demo

下面列出了java.awt.event.MouseEvent#isMetaDown() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: AMIDST   文件: MapViewer.java
@Override
public void mouseClicked(MouseEvent e) {
	if (!e.isMetaDown()) {
		Point mouse = e.getPoint(); // Don't use getMousePosition() because when computer is swapping/grinding, mouse may have moved out of window before execution reaches here.
		for (Widget widget : widgets) {
			if ((widget.isVisible()) &&
				(mouse.x > widget.getX()) &&
				(mouse.y > widget.getY()) &&
				(mouse.x < widget.getX() + widget.getWidth()) &&
				(mouse.y < widget.getY() + widget.getHeight())) {
				if (widget.onClick(mouse.x - widget.getX(), mouse.y - widget.getY()))
					return;
			}
		}
		MapObject object = worldMap.getObjectAt(mouse, 50.0);
		
		if (selectedObject != null)
			selectedObject.localScale = 1.0;

		if (object != null)
			object.localScale = 1.5;
		selectedObject = object;
	}
}
 
源代码2 项目: blog-codes   文件: mxGraphComponent.java
/**
 * 
 * @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;
}
 
源代码3 项目: marathonv5   文件: RComponent.java
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);
    }
}
 
源代码4 项目: audiveris   文件: UIPredicates.java
/**
 * Predicate to check if an additional selection is wanted.
 * Default is the typical selection (left button), while control key is pressed.
 *
 * @param e the mouse context
 * @return the predicate result
 */
public static boolean isAdditionWanted (MouseEvent e)
{
    if (WellKnowns.MAC_OS_X) {
        boolean command = e.isMetaDown();
        boolean left = SwingUtilities.isLeftMouseButton(e);

        return left && command && !e.isPopupTrigger();
    } else {
        return (SwingUtilities.isRightMouseButton(e) != SwingUtilities.isLeftMouseButton(e))
                       && e.isControlDown();
    }
}
 
源代码5 项目: megan-ce   文件: DataJTable.java
public void mousePressed(MouseEvent e) {
    if (e.isPopupTrigger()) {
        showPopupMenu(e);
    } else {
        if (e.getSource() instanceof JTableHeader) {
            columnPressed = jTable.getTableHeader().columnAtPoint(e.getPoint());
            if (columnPressed >= 0) {
                if (!e.isShiftDown() && !e.isMetaDown())
                    clearSelection();
                selectColumn(columnPressed, true);
            }
        }
    }
}
 
源代码6 项目: consulo   文件: EditorTabbedContainer.java
@Override
public void mouseClicked(MouseEvent e) {
  if (UIUtil.isActionClick(e, MouseEvent.MOUSE_CLICKED) && (e.isMetaDown() || !SystemInfo.isMac && e.isControlDown())) {
    final TabInfo info = myTabs.findInfo(e);
    if (info != null && info.getObject() != null) {
      final VirtualFile vFile = (VirtualFile)info.getObject();
      if (vFile != null) {
        ShowFilePathAction.show(vFile, e);
      }
    }
  }
}
 
源代码7 项目: KodeBeagle   文件: ProjectTree.java
public final MouseListener getMouseListener(final TreeNode root) {
    return new MouseAdapter() {
        @Override
        public void mouseClicked(final MouseEvent mouseEvent) {
            DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)
                    windowObjects.getjTree().getLastSelectedPathComponent();
            String url = "";
            if (mouseEvent.isMetaDown() && selectedNode != null
                    && selectedNode.getParent() != null) {
                final String gitUrl = getGitUrl(selectedNode, url, root);
                JPopupMenu menu = new JPopupMenu();

                if (selectedNode.isLeaf()) {
                    final CodeInfo codeInfo = (CodeInfo) selectedNode.getUserObject();

                    menu.add(new JMenuItem(addOpenInNewTabMenuItem(codeInfo))).
                            setText(OPEN_IN_NEW_TAB);
                }

                menu.add(new JMenuItem(new AbstractAction() {
                    @Override
                    public void actionPerformed(final ActionEvent actionEvent) {
                        if (!gitUrl.isEmpty()) {
                            BrowserUtil.browse(GITHUB_LINK + gitUrl);
                        }
                    }
                })).setText(RIGHT_CLICK_MENU_ITEM_TEXT);

                menu.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
            }
            doubleClickListener(mouseEvent);
        }
    };
}
 
源代码8 项目: consulo   文件: OnePixelDivider.java
@Override
protected void processMouseEvent(MouseEvent e) {
  super.processMouseEvent(e);
  if (e.getID() == MouseEvent.MOUSE_CLICKED) {
    if (mySwitchOrientationEnabled
        && e.getClickCount() == 1
        && SwingUtilities.isLeftMouseButton(e) && (SystemInfo.isMac ? e.isMetaDown() : e.isControlDown())) {
      mySplitter.setOrientation(!mySplitter.getOrientation());
    }
    if (myResizeEnabled && e.getClickCount() == 2) {
      mySplitter.setProportion(.5f);
    }
  }
}
 
源代码9 项目: libreveris   文件: UIPredicates.java
/**
 * Predicate to check if an additional selection is wanted.
 * Default is the typical selection (left button), while control key is
 * pressed.
 *
 * @param e the mouse context
 * @return the predicate result
 */
public static boolean isAdditionWanted (MouseEvent e)
{
    if (WellKnowns.MAC_OS_X) {
        boolean command = e.isMetaDown();
        boolean left = SwingUtilities.isLeftMouseButton(e);

        return left && command && !e.isPopupTrigger();
    } else {
        return (SwingUtilities.isRightMouseButton(e) != SwingUtilities.isLeftMouseButton(
                e)) && e.isControlDown();
    }
}
 
源代码10 项目: WorldPainter   文件: MouseOrTabletOperation.java
@Override
    public void mousePressed(MouseEvent me) {
        if ((me.getButton() != BUTTON1) && (me.getButton() != BUTTON3)) {
            // Only interested in left and right mouse buttons
            // TODO: the right mouse button is not button three on two-button
            //  mice, is it?
            return;
        }
        x = me.getX();
        y = me.getY();
        altDown = me.isAltDown() || me.isAltGraphDown();
        undo = (me.getButton() == BUTTON3) || altDown;
        ctrlDown = me.isControlDown() || me.isMetaDown();
        shiftDown = me.isShiftDown();
        first = true;
        if (! oneShot) {
            interrupt(); // Make sure any operation in progress (due to timing issues perhaps) is interrupted
            timer = new Timer(delay, e -> {
                Point worldCoords = view.viewToWorld((int) x, (int) y);
                tick(worldCoords.x, worldCoords.y, undo, first, 1.0f);
                view.updateStatusBar(worldCoords.x, worldCoords.y);
                first = false;
            });
            timer.setInitialDelay(0);
            timer.start();
            operationStartedWithButton = me.getButton();
            App.getInstance().pauseAutosave();
//            start = System.currentTimeMillis();
        } else {
            Point worldCoords = view.viewToWorld((int) x, (int) y);
            App.getInstance().pauseAutosave();
            try {
                tick(worldCoords.x, worldCoords.y, undo, true, 1.0f);
                view.updateStatusBar(worldCoords.x, worldCoords.y);
                Dimension dimension = getDimension();
                if (dimension != null) {
                    dimension.armSavePoint();
                }
                logOperation(undo ? statisticsKeyUndo : statisticsKey);
            } finally {
                App.getInstance().resumeAutosave();
            }
        }
        me.consume();
    }
 
源代码11 项目: netbeans   文件: JTreeTablePanel.java
private static boolean onlyShift(MouseEvent e) {
    return e.isShiftDown() && !(e.isAltDown() || e.isAltGraphDown() ||
                                e.isControlDown() || e.isMetaDown());
}
 
源代码12 项目: visualvm   文件: ProfilerTableContainer.java
private static boolean onlyShift(MouseEvent e) {
    return e.isShiftDown() && !(e.isAltDown() || e.isAltGraphDown() ||
                                e.isControlDown() || e.isMetaDown());
}
 
源代码13 项目: visualvm   文件: JTreeTablePanel.java
private static boolean onlyShift(MouseEvent e) {
    return e.isShiftDown() && !(e.isAltDown() || e.isAltGraphDown() ||
                                e.isControlDown() || e.isMetaDown());
}
 
源代码14 项目: amidst   文件: ViewerMouseListener.java
@CalledOnlyBy(AmidstThread.EDT)
private boolean isRightClick(MouseEvent e) {
	return e.isMetaDown();
}
 
源代码15 项目: consulo   文件: WideSelectionTreeUI.java
@Override
protected boolean isToggleSelectionEvent(MouseEvent e) {
  return SwingUtilities.isLeftMouseButton(e) && (SystemInfo.isMac ? e.isMetaDown() : e.isControlDown()) && !e.isPopupTrigger();
}
 
源代码16 项目: amidst   文件: ViewerMouseListener.java
@CalledOnlyBy(AmidstThread.EDT)
private boolean isRightClick(MouseEvent e) {
	return e.isMetaDown();
}
 
源代码17 项目: Darcula   文件: DarculaTreeUI.java
@Override
protected boolean isToggleSelectionEvent(MouseEvent e) {
  return SwingUtilities.isLeftMouseButton(e) && (SystemInfo.isMac ? e.isMetaDown() : e.isControlDown()) && !e.isPopupTrigger();
}
 
源代码18 项目: consulo   文件: XLineBreakpointManager.java
@Override
public void mouseClicked(final EditorMouseEvent e) {
  final Editor editor = e.getEditor();
  final MouseEvent mouseEvent = e.getMouseEvent();
  if (mouseEvent.isPopupTrigger() ||
      mouseEvent.isMetaDown() ||
      mouseEvent.isControlDown() ||
      mouseEvent.getButton() != MouseEvent.BUTTON1 ||
      DiffUtil.isDiffEditor(editor) ||
      !isInsideGutter(e, editor) ||
      ConsoleViewUtil.isConsoleViewEditor(editor) ||
      !isFromMyProject(editor) ||
      (editor.getSelectionModel().hasSelection() && myDragDetected)) {
    return;
  }

  PsiDocumentManager.getInstance(myProject).commitAllDocuments();
  final int line = EditorUtil.yPositionToLogicalLine(editor, mouseEvent);
  final Document document = editor.getDocument();
  final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
  if (line >= 0 && line < document.getLineCount() && file != null) {
    ActionManagerEx.getInstanceEx().fireBeforeActionPerformed(IdeActions.ACTION_TOGGLE_LINE_BREAKPOINT, e.getMouseEvent());

    final AsyncResult<XLineBreakpoint> lineBreakpoint =
            XBreakpointUtil.toggleLineBreakpoint(myProject, XSourcePositionImpl.create(file, line), editor, mouseEvent.isAltDown(), false);
    lineBreakpoint.doWhenDone(breakpoint -> {
      if (!mouseEvent.isAltDown() && mouseEvent.isShiftDown() && breakpoint != null) {
        breakpoint.setSuspendPolicy(SuspendPolicy.NONE);
        String selection = editor.getSelectionModel().getSelectedText();
        if (selection != null) {
          breakpoint.setLogExpression(selection);
        }
        else {
          breakpoint.setLogMessage(true);
        }
        // edit breakpoint
        DebuggerUIUtil.showXBreakpointEditorBalloon(myProject, mouseEvent.getPoint(), ((EditorEx)editor).getGutterComponentEx(), false, breakpoint);
      }
    });
  }
}
 
源代码19 项目: audiveris   文件: UIPredicates.java
/**
 * Predicate to check if the display should be rezoomed to fit as
 * close as possible to the rubber definition.
 * Default is to have both Shift and Control keys pressed when the mouse is
 * released.
 *
 * @param e the mouse context
 * @return the predicate result
 */
public static boolean isRezoomWanted (MouseEvent e)
{
    if (WellKnowns.MAC_OS_X) {
        return e.isMetaDown() && e.isShiftDown();
    } else {
        return e.isControlDown() && e.isShiftDown();
    }
}
 
源代码20 项目: libreveris   文件: UIPredicates.java
/**
 * Predicate to check if the display should be rezoomed to fit as
 * close as possible to the rubber definition.
 * Default is to have both Shift and Control keys pressed when the mouse is
 * released.
 *
 * @param e the mouse context
 * @return the predicate result
 */
public static boolean isRezoomWanted (MouseEvent e)
{
    if (WellKnowns.MAC_OS_X) {
        return e.isMetaDown() && e.isShiftDown();
    } else {
        return e.isControlDown() && e.isShiftDown();
    }
}