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:cz.babi.desktop.remoteme.common.Controller.java

/**
 * Right mouse click./*from w w  w  . j ava  2 s.  com*/
 */
public void mouseRightClick() {
    if (Common.DEBUG)
        LOGGER.debug("[mouseRightClick]");

    robot.mousePress(InputEvent.BUTTON3_MASK);
    robot.mouseRelease(InputEvent.BUTTON3_MASK);
}

From source file:com.artistech.tuio.mouse.MouseDriver.java

/**
 * Add Cursor Event./*from  w  w  w .ja  v  a2  s .  c om*/
 *
 * @param tcur
 */
@Override
public void addTuioCursor(TuioCursor tcur) {
    logger.trace(MessageFormat.format("add tuio cursor id: {0}", tcur.getCursorID()));

    int width = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();
    int height = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();

    boolean found = false;
    for (MutableTriple<Long, Integer, Integer> trip : curs) {
        if (trip.getLeft() == tcur.getSessionID()) {
            found = true;
            break;
        }
    }
    if (!found) {
        curs.add(new MutableTriple<>(tcur.getSessionID(), tcur.getScreenX(width), tcur.getScreenY(height)));
    }

    if (curs.size() == 1) {
        logger.debug(MessageFormat.format("add mouse move: ({0}, {1})",
                new Object[] { tcur.getScreenX(width), tcur.getScreenY(height) }));
        robot.mouseMove(tcur.getScreenX(width), tcur.getScreenY(height));
    } else {
        logger.debug(MessageFormat.format("add mouse press: {0}", tcur.getCursorID()));
        if (curs.size() == 2) {
            robot.mousePress(InputEvent.BUTTON1_MASK);
        } else {
            robot.mousePress(InputEvent.BUTTON3_MASK);
            robot.mouseRelease(InputEvent.BUTTON3_MASK);
        }
    }
}

From source file:EventTestPane.java

/**
 * Return a string representation of the modifiers for a MouseEvent. Note
 * that the methods called here are inherited from InputEvent.
 *//*from w w  w.j  av  a  2  s  . c  o  m*/
protected String mousemods(MouseEvent e) {
    int mods = e.getModifiers();
    String s = "";
    if (e.isShiftDown())
        s += "Shift ";
    if (e.isControlDown())
        s += "Ctrl ";
    if ((mods & InputEvent.BUTTON1_MASK) != 0)
        s += "Button 1 ";
    if ((mods & InputEvent.BUTTON2_MASK) != 0)
        s += "Button 2 ";
    if ((mods & InputEvent.BUTTON3_MASK) != 0)
        s += "Button 3 ";
    return s;
}

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

public void mouseEntered(MouseEvent e) {

    if (window != null && window.getFrame() != null) {
        java.awt.Window frame = window.getFrame();
        if ((frame instanceof java.awt.Frame) && frame == e.getSource()) {
            try {
                if (window.isRealized()) {
                    XWindow.setInputFocus(window.client, window.id, 1, (int) System.currentTimeMillis(), false);
                }//from w  w  w .  java 2 s  .  c  o  m
            } catch (Exception ee) {
                LOG.error(ee);
            }
            return;
        }
    }

    String str = CopyPaste.getString();
    if (!CopyPaste.isOwner() && str != null) {
        synchronized (window.screen.root) {
            Property p = window.screen.root.getProperty();
            while (p != null) {
                if (p.propertyName == 9)
                    break;
                p = p.next;
            }
            if (p != null) {
                p.data = str.getBytes();
                p.size = p.data.length;
            }
        }

        Selection sel = Selection.getSelection(1); // PRIMARY
        if (sel != null && sel.client != null) {
            int time = (int) System.currentTimeMillis();
            Event event = new Event();
            event.mkSelectionClear(time, sel.wid, sel.selection);
            try {
                sel.client.sendEvent(event, 1, Event.NoEventMask, Event.NoEventMask, null);
            } catch (Exception ee) {
                //System.out.println(ee);
            }
            ;
            sel.window = window.screen.root;
            sel.wid = window.screen.root.id;
            sel.lastTimeChanged = time;
            sel.client = null;
        }
        CopyPaste.setString(str);
    }

    if (window.id == window.screen.rootId) {
        return;
    }

    if (window.isMapped()) {
        requestFocus();
        XWindow.focus.win = window.id;
    }

    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();
    int state = 0;
    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;
    Client client = window.client;
    if (client == null || client == serverClient)
        return;

    event.mkEnterNotify(0, // Ancestor
            window.screen.rootId, window.id, 0, x, y, e.getX(), e.getY(), state, 0, // Normal
            0x1 | 0x02 // focus|same-screen
    );
    try {
        XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }
}

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

public void mouseEntered(MouseEvent e) {
    if (window == null)
        return;// w  ww  .  jav  a2 s  .  c  o  m
    if (window.getFrame() != null) {
        java.awt.Window frame = window.getFrame();
        if ((frame instanceof java.awt.Frame) && frame == e.getSource()) {
            try {
                if (window.isRealized()) {
                    XWindow.setInputFocus(window.client, window.id, 1, (int) System.currentTimeMillis(), false);
                }
            } catch (Exception ee) {
                LOG.error(ee);
            }
            return;
        }
    }

    String str = CopyPaste.getString();
    if (!CopyPaste.isOwner() && str != null) {
        synchronized (window.screen.root) {
            Property p = window.screen.root.getProperty();
            while (p != null) {
                if (p.propertyName == 9)
                    break;
                p = p.next;
            }
            if (p != null) {
                p.data = str.getBytes();
                p.size = p.data.length;
            }
        }

        Selection sel = Selection.getSelection(1); // PRIMARY
        if (sel != null && sel.client != null) {
            int time = (int) System.currentTimeMillis();
            Event event = new Event();
            event.mkSelectionClear(time, sel.wid, sel.selection);
            try {
                sel.client.sendEvent(event, 1, Event.NoEventMask, Event.NoEventMask, null);
            } catch (Exception ee) {
                //System.out.println(ee);
            }
            ;
            sel.window = window.screen.root;
            sel.wid = window.screen.root.id;
            sel.lastTimeChanged = time;
            sel.client = null;
        }
        CopyPaste.setString(str);
    }

    if (window.id == window.screen.rootId) {
        return;
    }

    if (window.isMapped()) {
        requestFocus();
        XWindow.focus.win = window.id;
    }

    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();
    int state = 0;
    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;
    Client client = window.client;
    if (client == null || client == serverClient)
        return;

    event.mkEnterNotify(0, // Ancestor
            window.screen.rootId, window.id, 0, x, y, e.getX(), e.getY(), state, 0, // Normal
            0x1 | 0x02 // focus|same-screen
    );
    try {
        XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }
}

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

public void mouseExited(MouseEvent e) {
    if (window == null)
        return;//from ww w .j  a v  a 2 s. c  o m

    if (window.id == window.screen.rootId) {
        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();
    int state = 0;
    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;
    Client client = window.client;
    if (client == null || client == serverClient)
        return;

    event.mkLeaveNotify(0, // Ancestor
            window.screen.rootId, window.id, 0, x, y, e.getX(), e.getY(), state, 0, // Normal
            0x1 | 0x02 // focus|same-screen
    );
    try {
        XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }
}

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

public void mousePressed(MouseEvent e) {
    if (threeButton) {
        if (threeBstate == s) {
            threeBPressed = e;//from  w  w  w . j  av a  2 s  .com
            threeBstate = sp;
            return;
        }
        if (threeBstate == sp
        //       || threeBstate==sppr
        ) {
            threeBPressed = null;
            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());
        }
    }

    procPressed(e);
}

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

private void procPressed(MouseEvent e) {
    int x = e.getX() + window.x;
    int y = e.getY() + window.y;
    XWindow.sprite.hot.x = x;//  w ww.  ja  va  2 s .  c o m
    XWindow.sprite.hot.y = y;
    int mod = e.getModifiers();
    if (mod == 0) {
        mod |= InputEvent.BUTTON1_MASK;
    } // ?????

    int state = 0;
    int detail = 1;
    if ((mod & InputEvent.BUTTON1_MASK) != 0)
        detail = 1;
    if ((mod & InputEvent.BUTTON2_MASK) != 0)
        detail = 2;
    if ((mod & InputEvent.BUTTON3_MASK) != 0)
        detail = 3;
    if ((mod & InputEvent.SHIFT_MASK) != 0)
        state |= 1;
    if ((mod & InputEvent.CTRL_MASK) != 0)
        state |= 4;
    // alt -> state|=8;

    Event.filters[Event.MotionNotify] = Event.PointerMotionMask | Event.ButtonMotionMask
            | ((Event.Button1Mask >> 1) << detail);

    event.mkButtonPress(detail, window.screen.rootId, window.id, 0, x, y, e.getX(), e.getY(), state, 1);

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

    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;
}

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

private void procPressed(MouseEvent e) {
    int x = e.getX() + window.x;
    int y = e.getY() + window.y;
    oldWindowx = window.x;/*from w  ww .j  a v  a2s .  c om*/
    oldWindowy = window.y;
    XWindow.sprite.hot.x = x;
    XWindow.sprite.hot.y = y;
    int mod = e.getModifiers();
    if (mod == 0) {
        mod |= InputEvent.BUTTON1_MASK;
    } // ?????

    int state = 0;
    int detail = 1;
    if ((mod & InputEvent.BUTTON1_MASK) != 0)
        detail = 1;
    if ((mod & InputEvent.BUTTON2_MASK) != 0)
        detail = 2;
    if ((mod & InputEvent.BUTTON3_MASK) != 0)
        detail = 3;
    if ((mod & InputEvent.SHIFT_MASK) != 0)
        state |= 1;
    if ((mod & InputEvent.CTRL_MASK) != 0)
        state |= 4;
    // alt -> state|=8;

    Event.filters[Event.MotionNotify] = Event.PointerMotionMask | Event.ButtonMotionMask
            | ((Event.Button1Mask >> 1) << detail);

    event.mkButtonPress(detail, window.screen.rootId, window.id, 0, x, y, e.getX(), e.getY(), state, 1);

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

    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;
}

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

public void mouseReleased(MouseEvent e) {
    if (threeButton) {
        if (threeBstate == sppr) {
            threeBPressed = null;/*  w ww.  ja va 2s  . c  om*/
            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());
        }
    }

    procReleased(e);
}