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

The following examples show how to use java.awt.event.InputEvent#getModifiersEx() . 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: DockableHeader.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void dragGestureRecognized(DragGestureEvent event) {
	if (!isDocking) {
		return;
	}

	// if any button other than MB1 is pressed, don't attempt to process the drag and drop event
	InputEvent ie = event.getTriggerEvent();
	int modifiers = ie.getModifiersEx();
	if ((modifiers & InputEvent.BUTTON2_DOWN_MASK) != 0 ||
		(modifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) {
		return;
	}
	DockableComponent.DROP_CODE = DropCode.WINDOW;
	DockableComponent.DROP_CODE_SET = true;
	DockableComponent.SOURCE_INFO = dockComp.getComponentWindowingPlaceholder();

	dragCursorManager.dragStarted();

	dragSource.startDrag(event, DragSource.DefaultMoveNoDrop,
		new ComponentTransferable(new ComponentTransferableData(dockComp)), this);
}
 
Example 2
Source File: GTreeDragNDropAdapter.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void dragGestureRecognized(DragGestureEvent dragEvent) {

	// check input event: if any button other than MB1 is pressed,
	// don't attempt to process the drag and drop event.
	InputEvent ie = dragEvent.getTriggerEvent();
	int modifiers = ie.getModifiersEx();
	if ((modifiers & InputEvent.BUTTON2_DOWN_MASK) != 0 ||
		(modifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) {
		return;
	}

	Point p = dragEvent.getDragOrigin();
	TreePath path = tree.getClosestPathForLocation(p.x, p.y);

	if (!tree.isPathSelected(path)) {
		return;
	}
	List<GTreeNode> selectedData = createSelectionList(tree.getSelectionPaths());
	if (!dragNDropHandler.isStartDragOk(selectedData, dragEvent.getDragAction())) {
		return;
	}

	Transferable transferable = new GTreeNodeTransferable(dragNDropHandler, selectedData);

	Image image = getDragImage(selectedData);

	try {
		dragEvent.startDrag(DragSource.DefaultCopyNoDrop, image, new Point(-10, -30),
			transferable, this);
	}
	catch (InvalidDnDOperationException exc) {
		Msg.debug(this, "Unable to initiate drag from tree", exc);
	}
}
 
Example 3
Source File: HyperlinkOperation.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private HyperlinkType getHyperlinkType(InputEvent e) {
    int modifiers = e.getModifiers() | e.getModifiersEx();
    if ((modifiers & altActionKeyMask) == altActionKeyMask && ((modifiers & InputEvent.SHIFT_MASK) == 0)) { // Ctrl/Cmd + Shift + Click is Add-Caret
        return HyperlinkType.ALT_HYPERLINK;
    } else if ((modifiers & actionKeyMask) == actionKeyMask && ((modifiers & InputEvent.SHIFT_MASK) == 0)) { // Ctrl/Cmd + Shift + Click is Add-Caret)
        return HyperlinkType.GO_TO_DECLARATION;
    }
    return null;
}
 
Example 4
Source File: DarkUIUtil.java    From darklaf with MIT License 4 votes vote down vote up
public static boolean isMenuShortcutKeyDown(final InputEvent event) {
    return (event.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0;
}
 
Example 5
Source File: BasicGraphicsUtils.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
static boolean isMenuShortcutKeyDown(InputEvent event) {
    return (event.getModifiersEx() &
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()) != 0;
}
 
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();
}
 
Example 7
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();
}