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

The following examples show how to use java.awt.event.InputEvent#isShiftDown() . 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: ChooseRunConfigurationPopup.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void handleSelect(boolean handleFinalChoices, InputEvent e) {
  if (e instanceof MouseEvent && e.isShiftDown()) {
    handleShiftClick(handleFinalChoices, e, this);
    return;
  }

  _handleSelect(handleFinalChoices, e);
}
 
Example 5
Source File: Utility.java    From pcgen with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * {@code isShiftLeftMouseButton} detects SHIFT-BUTTON1
 * events for flipping pane shortcuts.
 *
 * @param e {@code MouseEvent}, the event
 *
 * @return {@code boolean}, the condition
 */
@Contract(pure = true)
static boolean isShiftLeftMouseButton(InputEvent e)
{
	return ((e.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) == InputEvent.BUTTON1_DOWN_MASK) && e.isShiftDown();
}
 
Example 6
Source File: Utility.java    From pcgen with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * {@code isShiftLeftMouseButton} detects SHIFT-BUTTON1
 * events for flipping pane shortcuts.
 *
 * @param e {@code MouseEvent}, the event
 *
 * @return {@code boolean}, the condition
 */
@Contract(pure = true)
static boolean isShiftLeftMouseButton(InputEvent e)
{
	return ((e.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) == InputEvent.BUTTON1_DOWN_MASK) && e.isShiftDown();
}