Example usage for java.awt.event InputEvent BUTTON3_MASK

List of usage examples for java.awt.event InputEvent BUTTON3_MASK

Introduction

In this page you can find the example usage for java.awt.event InputEvent BUTTON3_MASK.

Prototype

int BUTTON3_MASK

To view the source code for java.awt.event InputEvent BUTTON3_MASK.

Click Source Link

Document

The Mouse Button3 modifier constant.

Usage

From source file:com.jcraft.weirdx.DDXWindowImp.java

public void mouseReleased(MouseEvent e) {
    if (threeButton) {
        if (threeBstate == sppr) {
            threeBPressed = null;/*from www. jav  a2s  .com*/
            threeBstate = s;
            return;
        }
        if (threeBstate == sp) {
            procPressed(threeBPressed);
            threeBPressed = null;
            threeBstate = s;
        } else if (threeBstate == spp) {
            threeBPressed = null;
            threeBstate = sppr;
            e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(),
                    (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK)))
                            | InputEvent.BUTTON2_MASK,
                    e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger());
        }
    }
    try {
        procReleased(e);
    } catch (Exception ee) {
    }
}

From source file:com.jcraft.weirdx.DDXWindowImp.java

private void procReleased(MouseEvent e) {
    int x = e.getX() + window.x;
    int y = e.getY() + window.y;

    XWindow.sprite.hot.x = x;//from  ww  w.java  2  s. c  o  m
    XWindow.sprite.hot.y = y;

    int mod = e.getModifiers();
    int state = 0;
    int detail = 0;

    if ((mod & InputEvent.BUTTON1_MASK) != 0) {
        state |= (1 << 8);
        detail = 1;
    }
    if ((mod & InputEvent.BUTTON2_MASK) != 0) {
        state |= (1 << 9);
        detail = 2;
    }
    if ((mod & InputEvent.BUTTON3_MASK) != 0) {
        state |= (1 << 10);
        detail = 3;
    }
    if ((mod & InputEvent.SHIFT_MASK) != 0)
        state |= 1;
    if ((mod & InputEvent.CTRL_MASK) != 0)
        state |= 4;
    // alt -> state|=8;
    XWindow.sprite.hot.state = 0; // ?????
    Event.filters[Event.MotionNotify] = Event.PointerMotionMask/*|
                                                               ((Event.Button1Mask>>1)<<detail)*/;
    event.mkButtonRelease(detail, window.screen.rootId, window.id, 0, x, y, e.getX(), e.getY(), state, 1);

    try {
        if (XWindow.grab != null)
            XWindow.sendGrabbedEvent(event, true, 1);
        else
            XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }
    XWindow.grab = null;
}

From source file:com.jcraft.weirdx.DDXWindowImpSwing.java

@SuppressWarnings("unused")
public void mouseDragged(MouseEvent e) {

    if (threeButton) {
        if (threeBstate != s) {
            if (threeBstate == sp) {
                procPressed(threeBPressed);
                threeBPressed = null;/*from w w  w  .j  a va  2 s .c  o m*/
                threeBstate = s;
            } else if (threeBstate == spp) {
                e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(),
                        (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK)))
                                | InputEvent.BUTTON2_MASK,
                        e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger());
            } else if (threeBstate == sppr) {
                return;
            }
        }
    }

    int x = e.getX() + window.x;
    int y = e.getY() + window.y;

    XWindow.sprite.hot.x = x;
    XWindow.sprite.hot.y = y;

    int mod = e.getModifiers();

    // button 1 -> 16
    // button 2 -> 8
    // button 3 -> 4
    // shift -> 1
    // control -> 2
    // alt -> 12 ?? 

    int state = 0;
    int detail = 0;

    if ((mod & InputEvent.BUTTON1_MASK) != 0) {
        state |= (1 << 8);
        detail = 1;
    }
    if ((mod & InputEvent.BUTTON2_MASK) != 0) {
        state |= (1 << 9);
        detail = 2;
    }
    if ((mod & InputEvent.BUTTON3_MASK) != 0) {
        state |= (1 << 10);
        detail = 3;
    }
    if ((mod & InputEvent.SHIFT_MASK) != 0)
        state |= 1;
    if ((mod & InputEvent.CTRL_MASK) != 0)
        state |= 4;
    // alt -> state|=8;
    XWindow.sprite.hot.state = state;

    px = x;
    py = y;

    event.mkMotionNotify(1, window.screen.rootId, /*window.id,*/
            XWindow.sprite.win.id, 0, px, py, e.getX(), e.getY(), state, 1);

    try {
        if (!XWindow.checkMotion(event, window)) {
            return;
        }
        event.mkMotionNotify(1, window.screen.rootId, /*window.id,*/
                XWindow.sprite.win.id, 0, px, py, px - XWindow.sprite.win.x, py - XWindow.sprite.win.y,
                //e.getX(),
                //e.getY(),
                state, 1);
        if (XWindow.grab != null)
            XWindow.sendGrabbedEvent(event, false, 1);
        else
            XWindow.sendDeviceEvent(XWindow.sprite.win, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }
}

From source file:com.jcraft.weirdx.DDXWindowImp.java

@SuppressWarnings("unused")
public void mouseDragged(MouseEvent e) {

    if (threeButton) {
        if (threeBstate != s) {
            if (threeBstate == sp) {
                procPressed(threeBPressed);
                threeBPressed = null;//w  w w.  ja va 2  s.co  m
                threeBstate = s;
            } else if (threeBstate == spp) {
                e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(),
                        (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK)))
                                | InputEvent.BUTTON2_MASK,
                        e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger());
            } else if (threeBstate == sppr) {
                return;
            }
        }
    }

    if (window == null)
        return;

    // calc abs cursor position use old window position for calculation
    // as mouseDragged (if you use Panel) delivers its coordinates relative to the position after mousepressed
    // UPDATE: this was a bug of the IBM JDK
    //    int x=e.getX()+oldwindowx;
    //    int y=e.getY()+oldwindowy;
    int x = e.getX() + window.x;
    int y = e.getY() + window.y;

    // set new drag position (absolute)
    XWindow.sprite.hot.x = x;
    XWindow.sprite.hot.y = y;

    int mod = e.getModifiers();

    // button 1 -> 16
    // button 2 -> 8
    // button 3 -> 4
    // shift -> 1
    // control -> 2
    // alt -> 12 ?? 

    int state = 0;
    int detail = 0;

    if ((mod & InputEvent.BUTTON1_MASK) != 0) {
        state |= (1 << 8);
        detail = 1;
    }
    if ((mod & InputEvent.BUTTON2_MASK) != 0) {
        state |= (1 << 9);
        detail = 2;
    }
    if ((mod & InputEvent.BUTTON3_MASK) != 0) {
        state |= (1 << 10);
        detail = 3;
    }
    if ((mod & InputEvent.SHIFT_MASK) != 0)
        state |= 1;
    if ((mod & InputEvent.CTRL_MASK) != 0)
        state |= 4;
    // alt -> state|=8;
    XWindow.sprite.hot.state = state;

    px = x;
    py = y;

    event.mkMotionNotify(1, window.screen.rootId, XWindow.sprite.win.id, 0, px, py, e.getX(), e.getY(), state,
            1);

    try {
        if (!XWindow.checkMotion(event, window)) {
            return;
        }
        event.mkMotionNotify(1, window.screen.rootId, XWindow.sprite.win.id, 0, px, py,
                px - XWindow.sprite.win.x, py - XWindow.sprite.win.y, state, 1);
        if (XWindow.grab != null) {
            XWindow.sendGrabbedEvent(event, false, 1);
        } else {
            XWindow.sendDeviceEvent(XWindow.sprite.win, event, XWindow.grab, null, 1);
        }
    } catch (Exception ee) {
    }
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java

/**
 * Opens the <tt>WritePanelRightButtonMenu</tt> when user clicks with the
 * right mouse button on the editor area.
 *
 * @param e the <tt>MouseEvent</tt> that notified us
 *//*from www . ja v  a  2  s.c o  m*/
public void mouseClicked(MouseEvent e) {
    if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || (e.isControlDown() && !e.isMetaDown())) {
        Point p = e.getPoint();
        SwingUtilities.convertPointToScreen(p, e.getComponent());

        //SPELLCHECK
        ArrayList<JMenuItem> contributedMenuEntries = new ArrayList<JMenuItem>();

        for (ChatMenuListener listener : this.menuListeners) {
            contributedMenuEntries.addAll(listener.getMenuElements(this.chatPanel, e));
        }

        for (JMenuItem item : contributedMenuEntries) {
            rightButtonMenu.add(item);
        }

        JPopupMenu rightMenu = rightButtonMenu.makeMenu(contributedMenuEntries);
        rightMenu.setInvoker(editorPane);
        rightMenu.setLocation(p.x, p.y);
        rightMenu.setVisible(true);
    }
}

From source file:com.jcraft.weirdx.DDXWindowImp.java

public void mouseMoved(MouseEvent e) {
    int x = e.getX() + window.x;
    int y = e.getY() + window.y;

    XWindow.sprite.hot.x = x;//from  w w w  .  j  av  a  2 s  .  c  o  m
    XWindow.sprite.hot.y = y;

    int mod = e.getModifiers();
    int state = 0;

    px = x;
    py = y;

    if ((mod & InputEvent.BUTTON1_MASK) != 0)
        state |= (1 << 8);
    if ((mod & InputEvent.BUTTON2_MASK) != 0)
        state |= (1 << 9);
    if ((mod & InputEvent.BUTTON3_MASK) != 0)
        state |= (1 << 10);
    if ((mod & InputEvent.SHIFT_MASK) != 0)
        state |= 1;
    if ((mod & InputEvent.CTRL_MASK) != 0)
        state |= 4;
    // alt -> state|=8;
    XWindow.sprite.hot.state = state;

    event.mkMotionNotify(0, window.screen.rootId, window.id, 0, x, y, x - window.x, y - window.y, state, 1);

    try {
        if (!XWindow.checkMotion(event, window)) {
            return;
        }
        if (XWindow.grab != null)
            XWindow.sendGrabbedEvent(event, false, 1);
        else
            XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }
}

From source file:com.peter.mavenrunner.MavenRunnerTopComponent.java

private void projectTreeKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_projectTreeKeyReleased
    if (evt.getKeyCode() == 525) {
        //         treePopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
        try {//from   w  w w .j a  v  a 2  s.  c  o m
            Robot robot = new Robot();
            robot.mousePress(InputEvent.BUTTON3_MASK);
            robot.mouseRelease(InputEvent.BUTTON3_MASK);
        } catch (AWTException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatConversationPanel.java

/**
 * When a right button click is performed in the editor pane, a popup menu
 * is opened./*w  w w.  j a va  2  s .com*/
 * In case of the Scheme being internal, it won't open the Browser but
 * instead it will trigger the forwarded action.
 *
 * @param e The MouseEvent.
 */
public void mouseClicked(MouseEvent e) {
    Point p = e.getPoint();
    SwingUtilities.convertPointToScreen(p, e.getComponent());

    if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || (e.isControlDown() && !e.isMetaDown())) {
        openContextMenu(p);
    } else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0 && currentHref != null
            && currentHref.length() != 0) {
        URI uri;
        try {
            uri = new URI(currentHref);
        } catch (URISyntaxException e1) {
            logger.error(
                    "Failed to open hyperlink in chat window. " + "Error was: Invalid URL - " + currentHref);
            return;
        }
        if ("jitsi".equals(uri.getScheme())) {
            for (ChatLinkClickedListener l : chatLinkClickedListeners) {
                l.chatLinkClicked(uri);
            }
        } else
            GuiActivator.getBrowserLauncher().openURL(currentHref);

        // after opening the link remove the currentHref to avoid
        // clicking on the window to gain focus to open the link again
        this.currentHref = "";
    }
}

From source file:org.gumtree.vis.awt.JChartPanel.java

@Override
public void mouseReleased(MouseEvent e) {
    if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
        double xNew = ChartMaskingUtilities.translateScreenX(e.getX(), getScreenDataArea(), getChart());
        double yNew = ChartMaskingUtilities.translateScreenY(e.getY(), getScreenDataArea(), getChart(), 0);
        mouseRightClickLocation = new Point2D.Double(xNew, yNew);
    }/*www .  j  ava2 s .c  om*/
    textMovePoint = null;
    super.mouseReleased(e);
}

From source file:gda.plots.SimplePlot.java

/**
 * Part of the implementation of MouseMotionListener - overrides the super class (ChartPanel) implementation so that
 * the mouse can be used to select a rectangle as well as for zooming.
 * //from   w ww  .j a  v a 2 s .  c o m
 * @param e
 *            the mouse event which caused the call
 */
@Override
public void mouseDragged(MouseEvent e) {
    // If the rectangle dragger is not in operation then call the
    // super class method (to deal with any possible zooming) then
    // deal with magnifyingImage or magnifyingData.

    if (rd == null) {
        super.mouseDragged(e);
        if ((magnifyingImage || magnifyingData) && (e.getModifiers() & InputEvent.BUTTON3_MASK) == 0) {
            Graphics2D g2 = (Graphics2D) getGraphics();
            g2.setXORMode(dragColour);
            if (magnifyRectangle != null) {
                if (magnifyRectangleIsNew) {
                    magnifyRectangleIsNew = false;
                } else {
                    g2.fill(magnifyRectangle);
                }
            }
            if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {
                magnifyWidth = e.getX() - magnifyXPoint;
                magnifyHeight = e.getY() - magnifyYPoint;
            }
            recalculateMagnifyRectangle(e);

            if ((e.getModifiers() & InputEvent.BUTTON2_MASK) != 0) {
                magnifier.update(magnifyRectangle);
            }

            if (magnifyRectangle != null) {
                g2.fill(magnifyRectangle);
            }
            g2.dispose();
        }
    } else {
        rd.mouseDragged(e);
    }
}