Example usage for java.awt.event InputEvent SHIFT_MASK

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

Introduction

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

Prototype

int SHIFT_MASK

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

Click Source Link

Document

The Shift key modifier constant.

Usage

From source file:dmh.kuebiko.view.NoteStackFrame.java

/**
 * Initialize the contents of the frame. The contents of this method was
 * generated by Window Builder Pro.//from  ww w  . j  av a  2s .  co m
 */
private void initialize() {
    setTitle(buildTitle());
    setBounds(100, 100, 450, 300);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0 };
    gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0 };
    gridBagLayout.columnWeights = new double[] { 0.0, 0.0, 1.0, Double.MIN_VALUE };
    gridBagLayout.rowWeights = new double[] { 0.0, 1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE };
    getContentPane().setLayout(gridBagLayout);

    horizontalStrut = Box.createHorizontalStrut(20);
    horizontalStrut.setMinimumSize(new Dimension(3, 0));
    horizontalStrut.setPreferredSize(new Dimension(3, 0));
    horizontalStrut.setSize(new Dimension(3, 0));
    GridBagConstraints gbc_horizontalStrut = new GridBagConstraints();
    gbc_horizontalStrut.insets = new Insets(0, 0, 0, 0);
    gbc_horizontalStrut.gridx = 0;
    gbc_horizontalStrut.gridy = 0;
    getContentPane().add(horizontalStrut, gbc_horizontalStrut);

    GridBagConstraints gbc_stateImageLabel = new GridBagConstraints();
    gbc_stateImageLabel.insets = new Insets(0, 0, 0, 0);
    gbc_stateImageLabel.anchor = GridBagConstraints.EAST;
    gbc_stateImageLabel.gridx = 1;
    gbc_stateImageLabel.gridy = 0;
    stateImageLabel.setBorder(null);
    stateImageLabel.setHorizontalAlignment(SwingConstants.CENTER);
    getContentPane().add(stateImageLabel, gbc_stateImageLabel);

    searchText = new JTextField();
    GridBagConstraints gbc_searchText = new GridBagConstraints();
    gbc_searchText.insets = new Insets(0, 0, 0, 0);
    gbc_searchText.fill = GridBagConstraints.HORIZONTAL;
    gbc_searchText.gridx = 2;
    gbc_searchText.gridy = 0;
    getContentPane().add(searchText, gbc_searchText);
    searchText.setColumns(10);
    if (SystemUtils.IS_OS_MAC_OSX) {
        // Make the text field look like the standard Mac OS X search
        // box control.
        searchText.putClientProperty("JTextField.variant", "search");
    }

    splitPane = new JSplitPane();
    splitPane.setBorder(null);
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    GridBagConstraints gbc_splitPane = new GridBagConstraints();
    gbc_splitPane.gridwidth = 3;
    gbc_splitPane.gridheight = 4;
    gbc_splitPane.insets = new Insets(0, 0, 0, 0);
    gbc_splitPane.fill = GridBagConstraints.BOTH;
    gbc_splitPane.gridx = 0;
    gbc_splitPane.gridy = 1;
    getContentPane().add(splitPane, gbc_splitPane);

    notePanel = new NotePanel();
    notePanel.getHuxleyUiManager().setOnTextChangeCallback(new Callback<Boolean>() {
        @Override
        public void callback(Boolean input) {
            toggleUnsavedChangeIndicator(input);
        }
    });
    splitPane.setRightComponent(notePanel);

    noteTableScroll = new JScrollPane();
    noteTableScroll.setMinimumSize(new Dimension(23, 100));
    splitPane.setLeftComponent(noteTableScroll);
    noteTable = newNoteTable();
    noteTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    noteTableScroll.setViewportView(noteTable);

    ActionObserverUtil.registerEnMass(actionMngr, observable,
            notePanel.getHuxleyUiManager().getTextAction(TextAction.INSERT_DATE));

    insertDateMenuItem = new JMenuItem(actionMngr.getAction(InsertDynamicTextAction.class));
    insertDateMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T,
            InputEvent.SHIFT_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    textMenu.add(insertDateMenuItem);
}

From source file:net.sf.jabref.gui.autocompleter.AutoCompleteListener.java

@Override
public void keyTyped(KeyEvent e) {
    LOGGER.debug("key typed event caught " + e.getKeyCode());
    char ch = e.getKeyChar();
    if (ch == '\n') {
        // this case is handled at keyPressed(e)
        return;/*from w ww.  j av a2s .  c  o  m*/
    }

    // don't do auto completion inside words
    if (!atEndOfWord((JTextComponent) e.getSource())) {
        return;
    }

    if ((e.getModifiers() | InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK) {
        // plain key or SHIFT + key is pressed, no handling of CTRL+key,  META+key, ...
        if (Character.isLetter(ch) || Character.isDigit(ch)
                || (Character.isWhitespace(ch) && completer.isSingleUnitField())) {
            JTextComponent comp = (JTextComponent) e.getSource();

            if (toSetIn == null) {
                LOGGER.debug("toSetIn is null");
            } else {
                LOGGER.debug("toSetIn: >" + toSetIn + '<');
            }

            // The case-insensitive system is a bit tricky here
            // If keyword is "TODO" and user types "tO", then this is treated as "continue" as the "O" matches the "O"
            // If keyword is "TODO" and user types "To", then this is treated as "discont" as the "o" does NOT match the "O".

            if ((toSetIn != null) && (toSetIn.length() > 1) && (ch == toSetIn.charAt(1))) {
                // User continues on the word that was suggested.
                LOGGER.debug("cont");

                toSetIn = toSetIn.substring(1);
                if (!toSetIn.isEmpty()) {
                    int cp = comp.getCaretPosition();
                    //comp.setCaretPosition(cp+1-toSetIn.);
                    comp.select((cp + 1) - toSetIn.length(), cp);
                    lastBeginning = lastBeginning + ch;

                    e.consume();
                    lastCaretPosition = comp.getCaretPosition();

                    lastCompletions = findCompletions(lastBeginning);
                    lastShownCompletion = 0;
                    for (int i = 0; i < lastCompletions.size(); i++) {
                        String lastCompletion = lastCompletions.get(i);
                        if (lastCompletion.endsWith(toSetIn)) {
                            lastShownCompletion = i;
                            break;
                        }

                    }
                    if (toSetIn.length() < 2) {
                        // User typed the last character of the autocompleted word
                        // We have to replace the automcompletion word by the typed word.
                        // This helps if the user presses "space" after the completion
                        // "space" indicates that the user does NOT want the autocompletion,
                        // but the typed word
                        String text = comp.getText();
                        comp.setText(text.substring(0, lastCaretPosition - lastBeginning.length())
                                + lastBeginning + text.substring(lastCaretPosition));
                        // there is no selected text, therefore we are not updating the selection
                        toSetIn = null;
                    }
                    return;
                }
            }

            if ((toSetIn != null) && ((toSetIn.length() <= 1) || (ch != toSetIn.charAt(1)))) {
                // User discontinues the word that was suggested.
                lastBeginning = lastBeginning + ch;

                LOGGER.debug("discont toSetIn: >" + toSetIn + "'<' lastBeginning: >" + lastBeginning + '<');

                List<String> completed = findCompletions(lastBeginning);
                if ((completed != null) && (!completed.isEmpty())) {
                    lastShownCompletion = 0;
                    lastCompletions = completed;
                    String sno = completed.get(0);
                    // toSetIn = string used for autocompletion last time
                    // this string has to be removed
                    // lastCaretPosition is the position of the caret after toSetIn.
                    int lastLen = toSetIn.length() - 1;
                    toSetIn = sno.substring(lastBeginning.length() - 1);
                    String text = comp.getText();
                    //we do not use toSetIn as we want to obey the casing of "sno"
                    comp.setText(text.substring(0, (lastCaretPosition - lastLen - lastBeginning.length()) + 1)
                            + sno + text.substring(lastCaretPosition));
                    int startSelect = (lastCaretPosition + 1) - lastLen;
                    int endSelect = (lastCaretPosition + toSetIn.length()) - lastLen;
                    comp.select(startSelect, endSelect);

                    lastCaretPosition = comp.getCaretPosition();
                    e.consume();
                    return;
                } else {
                    setUnmodifiedTypedLetters(comp, true, false);
                    e.consume();
                    toSetIn = null;
                    return;
                }
            }

            LOGGER.debug("case else");

            comp.replaceSelection("");

            StringBuffer currentword = getCurrentWord(comp);

            // only "real characters" end up here
            assert (!Character.isISOControl(ch));
            currentword.append(ch);
            startCompletion(currentword, e);
            return;
        } else {
            if (Character.isWhitespace(ch)) {
                assert (!completer.isSingleUnitField());
                LOGGER.debug("whitespace && !singleUnitField");
                // start a new search if end-of-field is reached

                // replace displayed letters with typed letters
                setUnmodifiedTypedLetters((JTextComponent) e.getSource(), false, true);
                resetAutoCompletion();
                return;
            }

            LOGGER.debug("No letter/digit/whitespace or CHAR_UNDEFINED");
            // replace displayed letters with typed letters
            setUnmodifiedTypedLetters((JTextComponent) e.getSource(), false, !Character.isISOControl(ch));
            resetAutoCompletion();
            return;
        }
    }
    resetAutoCompletion();
}

From source file:jpad.MainEditor.java

@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jScrollPane1 = new javax.swing.JScrollPane();
    mainTextArea = new javax.swing.JTextArea();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    openMenuItem = new javax.swing.JMenuItem();
    saveMenuItem = new javax.swing.JMenuItem();
    saveAsMenuItem = new javax.swing.JMenuItem();
    seperator_OpenAndExit = new javax.swing.JPopupMenu.Separator();
    exitMenuItem = new javax.swing.JMenuItem();
    jMenu2 = new javax.swing.JMenu();
    textWrapMenuItem = new javax.swing.JCheckBoxMenuItem();

    setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
    setTitle("JPad");
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);//from  ww w.  j a v  a 2  s .  co  m
        }
    });

    mainTextArea.setColumns(20);
    mainTextArea.setLineWrap(true);
    mainTextArea.setRows(5);
    jScrollPane1.setViewportView(mainTextArea);
    textChanged();

    jMenu1.setText("File");

    openMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    openMenuItem.setText("Open...");
    openMenuItem.setToolTipText("Open a file");
    openMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            openMenuItemActionPerformed(evt);
        }
    });
    jMenu1.add(openMenuItem);

    saveMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    saveMenuItem.setText("Save...");
    saveMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveMenuItemActionPerformed(evt);
        }
    });
    jMenu1.add(saveMenuItem);

    saveAsMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
            (java.awt.event.InputEvent.SHIFT_MASK | (Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()))));
    saveAsMenuItem.setText("Save As...");
    saveAsMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveAsMenuItemActionPerformed(evt);
        }
    });
    jMenu1.add(saveAsMenuItem);
    jMenu1.add(seperator_OpenAndExit);

    exitMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q,
            java.awt.event.InputEvent.CTRL_MASK));
    exitMenuItem.setText("Exit");
    exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            exitMenuItemActionPerformed(evt);
        }
    });
    jMenu1.add(exitMenuItem);
    if (_isOSX) {
        exitMenuItem.getParent().remove(exitMenuItem);
    }

    jMenuBar1.add(jMenu1);

    jMenu2.setText("Edit");

    textWrapMenuItem.setText("Text Wrap");
    textWrapMenuItem.setToolTipText("Enables or disables text wrap");
    textWrapMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            textWrapMenuItemActionPerformed(evt);
        }
    });
    jMenu2.add(textWrapMenuItem);
    if (mainTextArea.getLineWrap() == true) {
        textWrapMenuItem.setSelected(true);
    } else {
        textWrapMenuItem.setSelected(false);
    }

    jMenuBar1.add(jMenu2);

    setJMenuBar(jMenuBar1);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 581, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
            jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 543,
            Short.MAX_VALUE));

    pack();
}

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  ww .  j  a  v a2  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;/*from   w  ww.  jav  a2s  .  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;/* www.j a va  2s. 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.DDXWindowImpSwing.java

private void procPressed(MouseEvent e) {
    int x = e.getX() + window.x;
    int y = e.getY() + window.y;
    XWindow.sprite.hot.x = x;/*from   w  w w . ja  va 2  s  .co 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;//  w  w  w  .j  a v a  2 s.  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.DDXWindowImp.java

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

    XWindow.sprite.hot.x = x;/* w w w . ja  v  a  2  s .co 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;// ww w  .j a  v a 2  s  . c om
                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) {
    }
}