Java Code Examples for java.awt.event.InputEvent#isControlDown()

The following examples show how to use java.awt.event.InputEvent#isControlDown() . 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(InputEvent 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: PopupChoiceAction.java    From StringManipulation with Apache License 2.0 6 votes vote down vote up
@Override
public void update(AnActionEvent e) {
	super.update(e);
	Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
	if (editor == null) {
		e.getPresentation().setEnabled(false);
		return;
	}
	Project project = getEventProject(e);
	if (project != null) {
		InputEvent inputEvent = e.getInputEvent();
		boolean onlyAltDown = false;
		if (inputEvent != null) {
			onlyAltDown = inputEvent.isAltDown() && !inputEvent.isShiftDown() && !inputEvent.isMetaDown() && !inputEvent.isControlDown();
		}
		LookupEx activeLookup = LookupManager.getInstance(project).getActiveLookup();
		boolean dialogOpen = isFromDialog(project);
		boolean popupCheck = activeLookup == null || (activeLookup != null && !onlyAltDown);
		boolean dialogCheck = !dialogOpen || (dialogOpen && !onlyAltDown);
		e.getPresentation().setEnabled((popupCheck && dialogCheck));
	}
}
 
Example 3
Source File: SqueakDisplay.java    From trufflesqueak with MIT License 5 votes vote down vote up
public int recordModifiers(final InputEvent e) {
    final int shiftValue = e.isShiftDown() ? KEYBOARD.SHIFT : 0;
    final int ctrlValue = e.isControlDown() ? KEYBOARD.CTRL : 0;
    final int optValue = e.isAltDown() || e.isAltGraphDown() ? KEYBOARD.ALT : 0;
    final int cmdValue = e.isMetaDown() ? KEYBOARD.CMD : 0;
    final int modifiers = shiftValue + ctrlValue + optValue + cmdValue;
    buttons = buttons & ~KEYBOARD.ALL | modifiers;
    return modifiers;
}
 
Example 4
Source File: DesktopApi.java    From workcraft with MIT License 4 votes vote down vote up
public static boolean isMenuKeyDown(InputEvent e) {
    if (getOs().isMac()) {
        return e.isMetaDown();
    }
    return e.isControlDown();
}
 
Example 5
Source File: Utils.java    From TrakEM2 with GNU General Public License v3.0 4 votes vote down vote up
/** The CTRL key functionality is passed over to the COMMAND key (aka META key) in a MacOSX. */
static public final boolean isControlDown(final InputEvent e) {
	return IJ.isMacOSX() ? e.isMetaDown()
		             : e.isControlDown();
}