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

The following examples show how to use java.awt.event.InputEvent#getModifiers() . 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: DragGestureAdapter.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
	 * A <code>DragGestureRecognizer</code> has detected a 
	 * platform-dependent Drag and Drop action initiating gesture
	 * and is notifying this Listener in order for it to initiate
	 * the action for the user.
	 * <p>The <code>DragGestureRecognizer</code> hides the platform-specific
	 * events that initate a drag and drop operation.
	 * 
	 * @param e event describing the gesture that has just occurred
	 */
    public void dragGestureRecognized(DragGestureEvent e) {

        // check input event: if any button other than MB1 is pressed,
        // don't attempt to process the drag and drop event.
        InputEvent ie = e.getTriggerEvent();
        int modifiers = ie.getModifiers();
        if ((modifiers & InputEvent.BUTTON2_MASK) != 0 ||
            (modifiers & InputEvent.BUTTON3_MASK) != 0) {
            return;
        }
        int dragAction = dragComponent.getDragAction();
        
        if ( ((e.getDragAction() & dragAction) == 0) || 
            !dragComponent.isStartDragOk(e)) {
            return;
        }
        
        Transferable t = dragComponent.getTransferable(e.getDragOrigin());
        
        DragSourceListener l = dragComponent.getDragSourceListener();
        if (t == null || l == null) {
            return;
        }
//        transferable = t;
        try {
            e.startDrag(DragSource.DefaultCopyNoDrop, t, l);
        } catch (InvalidDnDOperationException exc) {
            // the Drag and Drop system is unable to initiate a drag operation
            Msg.error(this, "Exception occurred during drag initiation: " + exc, exc);

            //            transferable = null;
        }
    }
 
Example 2
Source File: AnActionEvent.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static AnActionEvent createFromInputEvent(@Nullable InputEvent event,
                                                 @Nonnull String place,
                                                 @Nonnull Presentation presentation,
                                                 @Nonnull DataContext dataContext,
                                                 boolean isContextMenuAction,
                                                 boolean isToolbarAction) {
  return new AnActionEvent(event, dataContext, place, presentation, ActionManager.getInstance(), event == null ? 0 : event.getModifiers(), isContextMenuAction, isToolbarAction);
}
 
Example 3
Source File: HTMLView.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private void invokeDefaultAction(URL url, InputEvent e) {
    HeapViewerNode node = nodeForURL(url, context);
    if (node == null) return;

    HeapViewerNodeAction.Actions nodeActions = HeapViewerNodeAction.Actions.forNode(node, actionProviders, context, actions);
    ActionEvent ae = e == null ? new ActionEvent(htmlComponent, ActionEvent.ACTION_PERFORMED, "link"): // NO18N
                                 new ActionEvent(e.getSource(), e.getID(), "link", e.getWhen(), e.getModifiers()); // NO18N
    nodeActions.performDefaultAction(ae);
}
 
Example 4
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 5
Source File: AnActionEvent.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static AnActionEvent createFromAnAction(@Nonnull AnAction action, @Nullable InputEvent event, @Nonnull String place, @Nonnull DataContext dataContext) {
  int modifiers = event == null ? 0 : event.getModifiers();
  Presentation presentation = action.getTemplatePresentation().clone();
  AnActionEvent anActionEvent = new AnActionEvent(event, dataContext, place, presentation, ActionManager.getInstance(), modifiers);
  anActionEvent.setInjectedContext(action.isInInjectedContext());
  return anActionEvent;
}
 
Example 6
Source File: BasicGraphicsUtils.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
static boolean isMenuShortcutKeyDown(InputEvent event) {
    return (event.getModifiers() &
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
}
 
Example 7
Source File: BasicGraphicsUtils.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
static boolean isMenuShortcutKeyDown(InputEvent event) {
    return (event.getModifiers() &
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
}
 
Example 8
Source File: BasicGraphicsUtils.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
static boolean isMenuShortcutKeyDown(InputEvent event) {
    return (event.getModifiers() &
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
}
 
Example 9
Source File: BasicGraphicsUtils.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
static boolean isMenuShortcutKeyDown(InputEvent event) {
    return (event.getModifiers() &
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
}
 
Example 10
Source File: BasicGraphicsUtils.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
static boolean isMenuShortcutKeyDown(InputEvent event) {
    return (event.getModifiers() &
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
}
 
Example 11
Source File: BasicGraphicsUtils.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
static boolean isMenuShortcutKeyDown(InputEvent event) {
    return (event.getModifiers() &
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
}
 
Example 12
Source File: BasicGraphicsUtils.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
static boolean isMenuShortcutKeyDown(InputEvent event) {
    return (event.getModifiers() &
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
}
 
Example 13
Source File: BasicGraphicsUtils.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
static boolean isMenuShortcutKeyDown(InputEvent event) {
    return (event.getModifiers() &
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
}
 
Example 14
Source File: RComponent.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public boolean isMenuShortcutKeyDown(InputEvent event) {
    return (event.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
}
 
Example 15
Source File: BasicGraphicsUtils.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
static boolean isMenuShortcutKeyDown(InputEvent event) {
    return (event.getModifiers() &
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
}
 
Example 16
Source File: BasicGraphicsUtils.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
static boolean isMenuShortcutKeyDown(InputEvent event) {
    return (event.getModifiers() &
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
}
 
Example 17
Source File: BasicGraphicsUtils.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
static boolean isMenuShortcutKeyDown(InputEvent event) {
    return (event.getModifiers() &
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
}
 
Example 18
Source File: BasicGraphicsUtils.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
static boolean isMenuShortcutKeyDown(InputEvent event) {
    return (event.getModifiers() &
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
}
 
Example 19
Source File: BasicGraphicsUtils.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
static boolean isMenuShortcutKeyDown(InputEvent event) {
    return (event.getModifiers() &
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
}
 
Example 20
Source File: CoreSwingUtils.java    From weblaf with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Returns whether or not specified {@link InputEvent} contains a menu shortcut key.
 *
 * @param event {@link InputEvent}
 * @return {@code true} if specified {@link InputEvent} contains a menu shortcut key, {@code false} otherwise
 */
public static boolean isMenuShortcutKeyDown ( @NotNull final InputEvent event )
{
    return ( event.getModifiers () & Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask () ) != 0;
}