Java Code Examples for javafx.scene.input.MouseEvent#isAltDown()

The following examples show how to use javafx.scene.input.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: WSRecorder.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
private String buildModifiersText(MouseEvent e) {
    StringBuilder sb = new StringBuilder();
    if (e.isAltDown()) {
        sb.append("Alt+");
    }
    if (e.isControlDown()) {
        sb.append("Ctrl+");
    }
    if (e.isMetaDown()) {
        sb.append("Meta+");
    }
    if (e.isShiftDown()) {
        sb.append("Shift+");
    }
    if (sb.length() > 0) {
        sb.setLength(sb.length() - 1);
    }
    String mtext = sb.toString();
    return mtext;
}
 
Example 2
Source File: SlideCheckBoxBehavior.java    From JFX8CustomControls with Apache License 2.0 6 votes vote down vote up
/**
 * Invoked when a mouse press has occurred over the button. In addition to
 * potentially arming the Button, this will transfer focus to the button
 */
@Override public void mousePressed(MouseEvent e) {
    final ButtonBase button = getControl();
    super.mousePressed(e);
    // if the button is not already focused, then request the focus
    if (! button.isFocused() && button.isFocusTraversable()) {
        button.requestFocus();
    }

    // arm the button if it is a valid mouse event
    // Note there appears to be a bug where if I press and hold and release
    // then there is a clickCount of 0 on the release, whereas a quick click
    // has a release clickCount of 1. So here I'll check clickCount <= 1,
    // though it should really be == 1 I think.
    boolean valid = (e.getButton() == MouseButton.PRIMARY &&
        ! (e.isMiddleButtonDown() || e.isSecondaryButtonDown() ||
            e.isShiftDown() || e.isControlDown() || e.isAltDown() || e.isMetaDown()));

    if (! button.isArmed() && valid) {
        button.arm();
    }
}
 
Example 3
Source File: AbstractMouseHandlerFX.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the specified mouse event has modifier
 * keys that match this handler.
 * 
 * @param e  the mouse event (<code>null</code> not permitted).
 * 
 * @return A boolean. 
 */
@Override
public boolean hasMatchingModifiers(MouseEvent e) {
    boolean b = true;
    b = b && (this.altKey == e.isAltDown());
    b = b && (this.ctrlKey == e.isControlDown());
    b = b && (this.metaKey == e.isMetaDown());
    b = b && (this.shiftKey == e.isShiftDown());
    return b;
}
 
Example 4
Source File: AbstractMouseHandlerFX.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the specified mouse event has modifier
 * keys that match this handler.
 * 
 * @param e  the mouse event (<code>null</code> not permitted).
 * 
 * @return A boolean. 
 */
@Override
public boolean hasMatchingModifiers(MouseEvent e) {
    boolean b = true;
    b = b && (this.altKey == e.isAltDown());
    b = b && (this.ctrlKey == e.isControlDown());
    b = b && (this.metaKey == e.isMetaDown());
    b = b && (this.shiftKey == e.isShiftDown());
    return b;
}
 
Example 5
Source File: OSFXUtils.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static String mouseEventGetModifiersExText(MouseEvent event) {
    StringBuffer sb = new StringBuffer();

    if (event.isControlDown()) {
        sb.append("Ctrl+");
    }
    if (event.isMetaDown()) {
        sb.append("Meta+");
    }
    if (event.isAltDown()) {
        sb.append("Alt+");
    }
    if (event.isShiftDown()) {
        sb.append("Shift+");
    }
    if (event.isPrimaryButtonDown()) {
        sb.append("Button1+");
    }
    if (event.isMiddleButtonDown()) {
        sb.append("Button2+");
    }
    if (event.isSecondaryButtonDown()) {
        sb.append("Button3+");
    }
    String text = sb.toString();
    if (text.equals("")) {
        return text;
    }
    return text.substring(0, text.length() - 1);
}
 
Example 6
Source File: FX.java    From FxDock with Apache License 2.0 5 votes vote down vote up
/** sometimes MouseEvent.isPopupTrigger() is not enough */
public static boolean isPopupTrigger(MouseEvent ev)
{
	if(ev.getButton() == MouseButton.SECONDARY)
	{
		if(CPlatform.isMac())
		{
			if
			(
				!ev.isAltDown() &&
				!ev.isMetaDown() &&
				!ev.isShiftDown()
			)
			{
				return true;
			}
		}
		else
		{
			if
			(
				!ev.isAltDown() &&
				!ev.isControlDown() &&
				!ev.isMetaDown() &&
				!ev.isShiftDown()
			)
			{
				return true;
			}
		}
	}
	return false;
}
 
Example 7
Source File: AbstractMouseHandlerFX.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the specified mouse event has modifier
 * keys that match this handler.
 * 
 * @param e  the mouse event (<code>null</code> not permitted).
 * 
 * @return A boolean. 
 */
@Override
public boolean hasMatchingModifiers(MouseEvent e) {
    boolean b = true;
    b = b && (this.altKey == e.isAltDown());
    b = b && (this.ctrlKey == e.isControlDown());
    b = b && (this.metaKey == e.isMetaDown());
    b = b && (this.shiftKey == e.isShiftDown());
    return b;
}
 
Example 8
Source File: AbstractMouseHandlerFX.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the specified mouse event has modifier
 * keys that match this handler.
 * 
 * @param e  the mouse event (<code>null</code> not permitted).
 * 
 * @return A boolean. 
 */
@Override
public boolean hasMatchingModifiers(MouseEvent e) {
    boolean b = true;
    b = b && (this.altKey == e.isAltDown());
    b = b && (this.ctrlKey == e.isControlDown());
    b = b && (this.metaKey == e.isMetaDown());
    b = b && (this.shiftKey == e.isShiftDown());
    return b;
}
 
Example 9
Source File: FileTreeCell.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Determines the {@link TransferMode} based on the state of the modifier key.
 * This method must consider the
 * operating system as the identity of the modifier key varies (alt/option on Mac OS, ctrl on the rest).
 * @param event The mouse event containing information on key press.
 * @return {@link TransferMode#COPY} if modifier key is pressed, otherwise {@link TransferMode#MOVE}.
 */
private TransferMode getTransferMode(MouseEvent event){
    if(event.isControlDown() && (PlatformInfo.is_linux || PlatformInfo.isWindows || PlatformInfo.isUnix)){
        return TransferMode.COPY;
    }
    else if(event.isAltDown() && PlatformInfo.is_mac_os_x){
        return TransferMode.COPY;
    }
    return TransferMode.MOVE;
}
 
Example 10
Source File: RFXComponent.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
protected void mousePressed(MouseEvent me) {
    if (me.isPrimaryButtonDown() && me.getClickCount() == 1 && !me.isAltDown() && !me.isMetaDown() && !me.isControlDown()) {
        mouseButton1Pressed(me);
    } else {
        recorder.recordClick2(this, me, true);
    }
}
 
Example 11
Source File: AbstractMouseHandlerFX.java    From jfreechart-fx with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Returns {@code true} if the specified mouse event has modifier
 * keys that match this handler.
 * 
 * @param e  the mouse event ({@code null} not permitted).
 * 
 * @return A boolean. 
 */
@Override
public boolean hasMatchingModifiers(MouseEvent e) {
    boolean b = true;
    b = b && (this.altKey == e.isAltDown());
    b = b && (this.ctrlKey == e.isControlDown());
    b = b && (this.metaKey == e.isMetaDown());
    b = b && (this.shiftKey == e.isShiftDown());
    return b;
}
 
Example 12
Source File: RFXTableView.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
protected void mouseClicked(MouseEvent me) {
    if (me.isControlDown() || me.isAltDown() || me.isMetaDown() || onCheckBox((Node) me.getTarget()))
        return;
    recorder.recordClick2(this, me, true);
}
 
Example 13
Source File: CloneOnClickHandler.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
protected boolean isCloneModifierDown(MouseEvent e) {
	return e.isAltDown() || e.isShiftDown();
}
 
Example 14
Source File: CreateCurveOnDragHandler.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void startDrag(MouseEvent event) {
	// create new curve
	GeometricCurve curve = new GeometricCurve(new Point[] { new Point(), new Point() },
			MvcLogoExample.GEF_COLOR_GREEN, MvcLogoExample.GEF_STROKE_WIDTH, MvcLogoExample.GEF_DASH_PATTERN, null);
	curve.addSourceAnchorage(getShapePart().getContent());

	// create using CreationPolicy from root part
	CreationPolicy creationPolicy = getHost().getRoot().getAdapter(CreationPolicy.class);
	init(creationPolicy);
	curvePart = (GeometricCurvePart) creationPolicy.create(curve, getHost().getRoot(),
			HashMultimap.<IContentPart<? extends Node>, String> create());
	commit(creationPolicy);

	// disable refresh visuals for the curvePart
	storeAndDisableRefreshVisuals(curvePart);

	// move curve to pointer location
	curvePart.getVisual().setEndPoint(getLocation(event));

	// build operation to deselect all but the new curve part
	List<IContentPart<? extends Node>> toBeDeselected = new ArrayList<>(
			getHost().getRoot().getViewer().getAdapter(SelectionModel.class).getSelectionUnmodifiable());
	toBeDeselected.remove(curvePart);
	DeselectOperation deselectOperation = new DeselectOperation(getHost().getRoot().getViewer(), toBeDeselected);
	// execute on stack
	try {
		getHost().getRoot().getViewer().getDomain().execute(deselectOperation, new NullProgressMonitor());
	} catch (ExecutionException e) {
		throw new RuntimeException(e);
	}

	// find bend target part
	bendTargetPart = findBendTargetPart(curvePart, event.getTarget());
	if (bendTargetPart != null) {
		dragPolicies = bendTargetPart.getAdapters(ClickDragGesture.ON_DRAG_POLICY_KEY);
	}
	if (dragPolicies != null) {
		MouseEvent dragEvent = new MouseEvent(event.getSource(), event.getTarget(), MouseEvent.MOUSE_DRAGGED,
				event.getX(), event.getY(), event.getScreenX(), event.getScreenY(), event.getButton(),
				event.getClickCount(), event.isShiftDown(), event.isControlDown(), event.isAltDown(),
				event.isMetaDown(), event.isPrimaryButtonDown(), event.isMiddleButtonDown(),
				event.isSecondaryButtonDown(), event.isSynthesized(), event.isPopupTrigger(),
				event.isStillSincePress(), event.getPickResult());
		for (IOnDragHandler dragPolicy : dragPolicies.values()) {
			dragPolicy.startDrag(event);
			// XXX: send initial drag event so that the end position is set
			dragPolicy.drag(dragEvent, new Dimension());
		}
	}
}
 
Example 15
Source File: RFXTreeView.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
protected void mouseClicked(MouseEvent me) {
    if (me.isControlDown() || me.isAltDown() || me.isMetaDown() || onCheckBox((Node) me.getTarget()))
        return;
    recorder.recordClick2(this, me, true);
}
 
Example 16
Source File: RFXListView.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
protected void mouseClicked(MouseEvent me) {
    if (me.isControlDown() || me.isAltDown() || me.isMetaDown() || onCheckBox((Node) me.getTarget()))
        return;
    recorder.recordClick2(this, me, true);
}
 
Example 17
Source File: RFXTreeTableView.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
protected void mouseClicked(MouseEvent me) {
    if (me.isControlDown() || me.isAltDown() || me.isMetaDown() || onCheckBox((Node) me.getTarget()))
        return;
    recorder.recordClick2(this, me, true);
}
 
Example 18
Source File: DragSupport.java    From scenic-view with GNU General Public License v3.0 4 votes vote down vote up
private boolean isModifierCorrect(MouseEvent t, KeyCode keyCode) {
    return (keyCode != KeyCode.ALT ^ t.isAltDown())
            && (keyCode != KeyCode.CONTROL ^ t.isControlDown())
            && (keyCode != KeyCode.SHIFT ^ t.isShiftDown())
            && (keyCode != KeyCode.META ^ t.isMetaDown());
}
 
Example 19
Source File: MouseEventsHelper.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
public static boolean modifierKeysUp(final MouseEvent event) {
    return !event.isAltDown() && !event.isControlDown() && !event.isMetaDown() && !event.isShiftDown();
}
 
Example 20
Source File: MouseEventsHelper.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
public static boolean isOnlyCtrlModifierDown(final MouseEvent event) {
    return event.isControlDown() && !event.isAltDown() && !event.isMetaDown() && !event.isShiftDown();
}