Java Code Examples for java.awt.event.MouseEvent#isAltDown()

The following examples show how to use java.awt.event.MouseEvent#isAltDown() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EditorTabbedContainer.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void mouseReleased(MouseEvent e) {
  if (UIUtil.isCloseClick(e, MouseEvent.MOUSE_RELEASED)) {
    final TabInfo info = myTabs.findInfo(e);
    if (info != null) {
      IdeEventQueue.getInstance().blockNextEvents(e);
      if (e.isAltDown() && e.getButton() == MouseEvent.BUTTON1) {//close others
        List<TabInfo> allTabInfos = myTabs.getTabs();
        for (TabInfo tabInfo : allTabInfos) {
          if (tabInfo == info) continue;
          FileEditorManagerEx.getInstanceEx(myProject).closeFile((VirtualFile)tabInfo.getObject(), myWindow);
        }
      }
      else {
        FileEditorManagerEx.getInstanceEx(myProject).closeFile((VirtualFile)info.getObject(), myWindow);
      }
    }
  }
}
 
Example 2
Source File: NamesPanel.java    From megan-ce with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void mouseClicked(MouseEvent me) {
    super.mouseClicked(me);
    int inClick = 1;
    current = inClick;
    if (me.getClickCount() == 1) {
        if (me.isShiftDown()) {
            if (selectedBlock.isSelected()) {
                if (!selectedBlock.isSelectedRow(getRow(me.getPoint())))
                    selectedBlock.extendSelection(getRow(me.getPoint()), -1);
                else
                    selectedBlock.reduceSelection(getRow(me.getPoint()), -1);
            }
        } else if (!selectedBlock.contains(getRow(me.getPoint()), getCol(me.getPoint()))) {
            selectedBlock.clear();
        }
    } else if (me.getClickCount() == 2) {
        if (!me.isAltDown())
            selectedBlock.selectRow(getRow(me.getPoint()));
    }
}
 
Example 3
Source File: RectangleCreator.java    From salty-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void mouseClicked(final MouseEvent e) {

    if (currentTransform == null || Input.getKeyboardInput().isSpace()) {
        final float x = Input.getCursorPosition().getX();
        final float y = Input.getCursorPosition().getY();

        origin.setX(x);
        origin.setY(y);

        upRight.setX(x + 100);
        upRight.setY(y);

        downRight.setX(x + 100);
        downRight.setY(y + 100);

        downLeft.setX(x);
        downLeft.setY(y + 100);
    } else if (e.isShiftDown() || e.isAltDown()) {
        savedTransforms.add(currentTransform);
        rects.addTag("rect" + savedTransforms.size(), currentTransform.getX() + "f, " + currentTransform.getY() + "f, " + currentTransform.getWidth() + "f, " + currentTransform.getHeight() + "f");
        currentTransform = null;
    }
}
 
Example 4
Source File: AxisAlignedQuad.java    From jtk with Apache License 2.0 6 votes vote down vote up
public void dragBegin(DragContext dc) {
  Point3 origin = dc.getPointWorld();
  Vector3 normal = null;
  Axis axis = _frame.getAxis();
  if (axis==Axis.X) {
    normal = new Vector3(1.0,0.0,0.0);
  } else if (axis==Axis.Y) {
    normal = new Vector3(0.0,1.0,0.0);
  } else if (axis==Axis.Z) {
    normal = new Vector3(0.0,0.0,1.0);
  }
  Plane plane = new Plane(origin,normal);
  MouseEvent event = dc.getMouseEvent();
  Matrix44 worldToPixel = dc.getWorldToPixel();
  if (event.isControlDown() || event.isAltDown()) { // Alt/Option for Mac
    _mouseConstrained = new MouseOnPlane(event,origin,plane,worldToPixel);
  } else {
    _mouseConstrained = new MouseOnLine(event,origin,normal,worldToPixel);
  }
  _origin = origin;
  _qa = _frame.getCornerMin();
  _qb = _frame.getCornerMax();
}
 
Example 5
Source File: Treeline.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void mouseReleased(final MouseEvent me, final Layer la, final int x_p, final int y_p, final int x_d, final int y_d, final int x_r, final int y_r) {
	if (null == getActive()) return;

	if (me.isShiftDown() && me.isAltDown() && !Utils.isControlDown(me)) {
		updateViewData(getActive());
		return;
	}
	super.mouseReleased(me, la, x_p, y_p, x_d, y_d, x_r, y_r);
}
 
Example 6
Source File: CartesianInteractive.java    From osp with GNU General Public License v3.0 5 votes vote down vote up
public void mouseMoved(MouseEvent e) {
  if (!enabled) return; // Paco
  altDown = e.isAltDown();
  Point p = e.getPoint();
  mouseRegion = findRegion(p);
  if((mouseRegion>INSIDE)&&(mouseRegion<HORZ_AXIS)&&!drawingPanel.isFixedScale()) {
    getScaleSetter().setRegion(mouseRegion);
    scaleSetter.validate();
    scaleSetter.setVisible(true);
  } else {
    scaleSetter.hideIfInactive();
  }
  drawHitRect = ((mouseRegion==HORZ_VAR)||(mouseRegion==VERT_VAR));
  plot.repaint();
}
 
Example 7
Source File: TestCaseAutoSuggest.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
@Override
public void mouseClicked(MouseEvent me) {
    if (me.isAltDown()) {
        if (table.rowAtPoint(me.getPoint()) != -1 && getTestCase(table) != null) {
            TestStep step = getTestCase(table).getTestSteps().get(table.rowAtPoint(me.getPoint()));
            if (isDataBaseQueryStep(step) && table.columnAtPoint(me.getPoint()) == Input.getIndex()) {
                new SQLTextArea(null, step, getInputs());
            }
        }
    }
}
 
Example 8
Source File: EditorCaret.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void mouseReleased(MouseEvent evt) {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("EditorCaret.mouseReleased: " + logMouseEvent(evt) + ", state=" + mouseState + '\n'); // NOI18N
    }

    int offset = mouse2Offset(evt);
    switch (mouseState) {
        case DRAG_SELECTION_POSSIBLE:
            setDot(offset);
            adjustRectangularSelectionMouseX(evt.getX(), evt.getY()); // also fires state change
            break;

        case CHAR_SELECTION:
            if (evt.isAltDown() && evt.isShiftDown()) {
                moveDot(offset);
            } else {
                moveDot(offset); // Will do setDot() if no selection
                adjustRectangularSelectionMouseX(evt.getX(), evt.getY()); // also fires state change
            }
            break;
    }
    // Set DEFAULT state; after next mouse press the state may change
    // to another state according to particular click count
    mouseState = MouseState.DEFAULT;
    component.setDragEnabled(true);
}
 
Example 9
Source File: UIPredicates.java    From libreveris with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Predicate to check whether the zoomed display must be dragged.
 * This method can simply be overridden to adapt to another policy.
 * Default is to have both left and right buttons pressed when moving.
 *
 * @param e the mouse event to check
 * @return true if drag is desired
 */
public static boolean isDragWanted (MouseEvent e)
{
    if (WellKnowns.MAC_OS_X) {
        return e.isAltDown();
    } else {
        int onmask = BUTTON1_DOWN_MASK | BUTTON3_DOWN_MASK;
        int offmask = 0;

        return (e.getModifiersEx() & (onmask | offmask)) == onmask;
    }
}
 
Example 10
Source File: NamesPanel.java    From megan-ce with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void mousePressed(MouseEvent me) {
    super.mousePressed(me);
    mouseDown = me.getPoint();
    paintedRubberband = false;
    boolean shiftDown = me.isShiftDown();

    if (me.isAltDown() || me.isShiftDown()) {
        current = inRubberband;
        setCursor(Cursor.getDefaultCursor());
    } else {
        current = inScrollByMouse;
        setCursor(Cursors.getClosedHand());

        stillDownWithoutMoving = true;

        final Thread worker = new Thread(new Runnable() {
            public void run() {
                try {
                    synchronized (this) {
                        wait(500);
                    }
                } catch (InterruptedException ignored) {
                }
                if (stillDownWithoutMoving) {
                    current = inRubberband;
                    setCursor(Cursor.getDefaultCursor());
                }
            }
        });
        worker.setPriority(Thread.currentThread().getPriority() - 1);
        worker.start();
    }
}
 
Example 11
Source File: CNodeClickHandler.java    From binnavi with Apache License 2.0 5 votes vote down vote up
/**
 * Handles right-clicks on nodes.
 *
 * @param node The node where the user clicked.
 * @param event Mouse-event that was created when the user clicked.
 * @param x The x location where the user clicked.
 * @param y The y location where the user clicked.
 * @param extensions List of objects that extend code node context menus.
 */
private void handleRightClick(final NaviNode node, final MouseEvent event, final double x,
    final double y, final List<ICodeNodeExtension> extensions) {
  final Object positionObject = ZyNodeContentHelpers.getObject(node, x, y);

  if (event.isAltDown() && event.isShiftDown()) {
    m_grayer.handleGrayLine(m_model, node, y);
  } else if (event.isAltDown() && event.isControlDown()) {
    m_highlighter.handleHighlightLine(node, y);
  } else if (event.isAltDown()) {
    if (positionObject instanceof CLocalNodeCommentWrapper) {
      CNodeFunctions.editNodeComments(m_model,
          ((CLocalNodeCommentWrapper) positionObject).getNode(), InitialTab.LocalNodeComments);
    } else if (positionObject instanceof CGlobalNodeCommentWrapper) {
      CNodeFunctions.editNodeComments(m_model,
          ((CGlobalNodeCommentWrapper) positionObject).getNode(), InitialTab.GlobalNodeComments);
    } else if (node.getRawNode() instanceof INaviCodeNode) {
      handleShowInstructionComment(node, y);
    }
  } else if (event.isShiftDown()) {
    handleBreakpointClick(node, y);
  } else if (event.isControlDown() && positionObject instanceof COperandTreeNode) {
    handleDoRegisterTrackingDown(node, y, x, (COperandTreeNode) positionObject);
  } else if (event.isControlDown() && event.isShiftDown()
      && positionObject instanceof COperandTreeNode) {
    handleDoRegisterTrackingUp(node, y, x, (COperandTreeNode) positionObject);
  } else {
    showPopupMenu(node, event, positionObject, y, extensions);
  }
}
 
Example 12
Source File: PointLogger.java    From salty-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void mouseClicked(final MouseEvent e) {

    if (e.isAltDown() || e.isShiftDown()) {
        System.out.println("Enter a name for point " + getPointIndicator(lastPoint) + " and press [ENTER]");
        final String name = scanner.nextLine();
        points.addTag(name, lastPoint.getX() + ", " + lastPoint.getY());
        savedPoints.add(lastPoint);
        System.out.println("Successfully added the point " + name + " to the save-queue. Exiting the game will automatically save them all.");
    } else {
        lastPoint = Input.getCursorPosition();
        System.out.println("Temporally saved " + getPointIndicator(lastPoint) + " as the last point. Click while holding shift or alt to save it.");
    }
}
 
Example 13
Source File: AlignmentPanel.java    From megan-ce with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void mousePressed(MouseEvent me) {
    super.mousePressed(me);
    mouseDown = me.getPoint();
    boolean shiftDown = me.isShiftDown();
    requestFocusInWindow();

    if (me.isAltDown() || me.isShiftDown()) {
        current = inRubberband;
        setCursor(Cursor.getDefaultCursor());
    } else {
        current = inScrollByMouse;
        setCursor(Cursors.getClosedHand());

        stillDownWithoutMoving = true;

        final Thread worker = new Thread(new Runnable() {
            public void run() {
                try {
                    synchronized (this) {
                        wait(500);
                    }
                } catch (InterruptedException ignored) {
                }
                if (stillDownWithoutMoving) {
                    current = inRubberband;
                    setCursor(Cursor.getDefaultCursor());
                }
            }
        });
        worker.setPriority(Thread.currentThread().getPriority() - 1);
        worker.start();
    }
}
 
Example 14
Source File: AligPanelMouseMotionListener.java    From biojava with GNU Lesser General Public License v2.1 4 votes vote down vote up
private boolean keyPressed(MouseEvent e) {
	if ( e.isShiftDown() || e.isControlDown() || e.isAltDown())
		return true;
	return false;
}
 
Example 15
Source File: MouseOrTabletOperation.java    From WorldPainter with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void mouseMoved(MouseEvent me) {
    altDown = me.isAltDown() || me.isAltGraphDown();
    ctrlDown = me.isControlDown() || me.isMetaDown();
    shiftDown = me.isShiftDown();
}
 
Example 16
Source File: HandTool.java    From MogwaiERDesignerNG with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean isForceMarqueeEvent(MouseEvent e) {
    return SwingUtilities.isRightMouseButton(e) && !e.isAltDown();
}
 
Example 17
Source File: CMousePressedHandler.java    From binnavi with Apache License 2.0 4 votes vote down vote up
public static IMouseStateChange handleMousePressed(final CStateFactory<?, ?> factory,
    final IMouseState defaultState, final AbstractZyGraph<?, ?> graph, final MouseEvent event) {
  final double x = graph.getEditMode().translateX(event.getX());
  final double y = graph.getEditMode().translateY(event.getY());

  final HitInfo hitInfo = graph.getGraph().getHitInfo(x, y);

  if (hitInfo.hasHitNodes()) {
    final Node n = hitInfo.getHitNode();

    if (SwingUtilities.isLeftMouseButton(event) && !event.isAltDown()) {
      return new CStateChange(factory.createNodePressedLeftState(n, event), true);
    } else if (SwingUtilities.isRightMouseButton(event)) {
      return new CStateChange(factory.createNodePressedRightState(n, event), true);
    } else if (SwingUtilities.isMiddleMouseButton(event)
        || (event.isAltDown() && SwingUtilities.isLeftMouseButton(event))) {
      return new CStateChange(factory.createNodePressedMiddleState(n, event), false);
    } else {
      // A button was pressed that does not have any special functionality.

      return new CStateChange(defaultState, true);
    }
  } else if (hitInfo.hasHitNodeLabels()) {
    throw new IllegalStateException("yFiles Labels are not in use...");
  } else if (hitInfo.hasHitEdges()) {
    final Edge edge = hitInfo.getHitEdge();

    if (SwingUtilities.isLeftMouseButton(event)) {
      return new CStateChange(factory.createEdgePressedLeftState(edge, event), true);
    } else if (SwingUtilities.isRightMouseButton(event)) {
      return new CStateChange(factory.createEdgePressedRightState(edge, event), true);
    } else {
      return new CStateChange(defaultState, true);
    }
  } else if (hitInfo.hasHitEdgeLabels()) {
    // final EdgeLabel label = hitInfo.getHitEdgeLabel();
    //
    // if (SwingUtilities.isLeftMouseButton(event))
    // {
    // return new CStateChange(factory.createEdgeLabelPressedLeftState(label, event), true);
    // }
    // else if (SwingUtilities.isRightMouseButton(event))
    // {
    // return new CStateChange(factory.createEdgeLabelPressedRightState(label, event), true);
    // }
    // else
    // {
    return new CStateChange(defaultState, true);
    // }
  } else if (hitInfo.hasHitBends()) {
    final Bend bend = hitInfo.getHitBend();

    if (SwingUtilities.isLeftMouseButton(event)) {
      return new CStateChange(factory.createBendPressedLeftState(bend, event), true);
    } else {
      return new CStateChange(defaultState, true);
    }
  } else if (hitInfo.hasHitPorts()) {
    return new CStateChange(factory.createDefaultState(), true);
  } else {
    if (SwingUtilities.isLeftMouseButton(event)) {
      return new CStateChange(factory.createBackgroundPressedLeftState(event), true);
    } else if (SwingUtilities.isRightMouseButton(event)) {
      return new CStateChange(factory.createBackgroundPressedRightState(event), true);
    }

    return new CStateChange(factory.createDefaultState(), true);
  }
}
 
Example 18
Source File: UIMouse.java    From open-ig with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Create an UIMouse from a Mouse Event.
 * @param e the mouse event
 * @return the UI mouse
 */
public static UIMouse from(MouseEvent e) {
	UIMouse m = new UIMouse();
	m.x = e.getX();
	m.y = e.getY();
	if (SwingUtilities.isLeftMouseButton(e)) {
		m.buttons.add(Button.LEFT);
	}
	if (SwingUtilities.isMiddleMouseButton(e)) {
		m.buttons.add(Button.MIDDLE);
	}
	if (SwingUtilities.isRightMouseButton(e)) {
		m.buttons.add(Button.RIGHT);
	}
	if (e.isShiftDown()) {
		m.modifiers.add(Modifier.SHIFT);
	}
	if (e.isControlDown()) {
		m.modifiers.add(Modifier.CTRL);
	}
	if (e.isAltDown()) {
		m.modifiers.add(Modifier.ALT);
	}
	switch (e.getID()) {
	case MouseEvent.MOUSE_CLICKED:
		m.type = e.getClickCount() == 1 ? Type.CLICK : Type.DOUBLE_CLICK;
		m.z = e.getClickCount();
		break;
	case MouseEvent.MOUSE_PRESSED:
		m.type = Type.DOWN;
		break;
	case MouseEvent.MOUSE_RELEASED:
		m.type = Type.UP;
		break;
	case MouseEvent.MOUSE_MOVED:
		m.type = Type.MOVE;
		break;
	case MouseEvent.MOUSE_DRAGGED:
		m.type = Type.DRAG;
		break;
	case MouseEvent.MOUSE_ENTERED:
		m.type = Type.ENTER;
		break;
	case MouseEvent.MOUSE_EXITED:
		m.type = Type.LEAVE;
		break;
	case MouseEvent.MOUSE_WHEEL:
		m.type = Type.WHEEL;
		m.z = ((MouseWheelEvent)e).getUnitsToScroll();
		break;
	default:
	}
	
	return m;
}
 
Example 19
Source File: PreviewViewControllerBase.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
void registerLastEvent(MouseEvent event) {
  lastPoint = event.getPoint();
  controlDown = event.isControlDown();
  altDown = event.isAltDown();
  updateMouseCursor();
}
 
Example 20
Source File: CharMap4Grid.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
public void mouseReleased(MouseEvent event) {
    // Called after a mouse button is released, and before mouseClicked(). If
    // the mouse moves too much, then Java doesn't call mouseClicked(), so we use
    // this method to implement our own rules for how much a mouse can move while
    // being clicked.

    int index; // cell index for character or glyph
    boolean repaint; // true if we should repaint our display

    index = convertMouse(event); // convert pixel coordinates to index value
    repaint = false; // assume that we won't need to repaint
    if ((index >= 0) // only if mouse is over defined character
            && (clickIndex == index) // and it's the same as when mouse pressed
            && (Math.abs(clickStartX - event.getX()) <= MOUSE_DRIFT)
            && (Math.abs(clickStartY - event.getY()) <= MOUSE_DRIFT)) {
        /* Mouse is over a defined character or glyph. */

        if ((event.getButton() != MouseEvent.BUTTON1) // right means not primary
                || event.isAltDown()
                || event.isControlDown()
                || event.isShiftDown()) {
            // TODO
            // CharMap4.rightSaveCaption = CharMap4.statusDialog.getText(); // caption
            // CharMap4.rightSaveChar = cellChar[index]; // save character number
            // CharMap4.rightSaveGlyph = cellGlyph[index]; // save glyph number
            //
            // CharMap4.rightCopyCaption.setEnabled((CharMap4.rightSaveCaption != null)
            // && (CharMap4.rightSaveCaption.length() > 0));
            // CharMap4.rightCopyGlyph.setEnabled(CharMap4.rightSaveGlyph >= 0);
            // CharMap4.rightCopyNotation.setEnabled(CharMap4.rightSaveChar >= 0);
            // CharMap4.rightCopyNumber.setEnabled(CharMap4.rightSaveChar >= 0);
            // CharMap4.rightCopyText.setEnabled(CharMap4.rightSaveChar >= 0);
        } else {
            // A left click or primary button click copies the character as text,
            // if there is a unique character number.

            if (cellChar[index] >= 0) {
                mouseReplaceText(CharMap4.unicodeNotation(cellChar[index]), index);
            }
        }
    }

    // Avoid redrawing the screen unless the mouse has changed cells.

    if (clickIndex >= 0) // mouse release always ends click highlight
    {
        clickIndex = NO_MOUSE; // this character is no longer highlighted
        repaint = true; // mark ourselves as needing to be repainted
    }
    clickStartX = clickStartY = NO_MOUSE; // no starting coordinates for click

    if (hoverIndex != index) // has there been a change in position?
    {
        hoverIndex = index; // turn on highlighting for this character
        repaint = true; // mark ourselves as needing to be repainted
    }

    if (repaint) this.repaint(); // repaint our display if something changed
}