Example usage for java.awt.event KeyEvent isMetaDown

List of usage examples for java.awt.event KeyEvent isMetaDown

Introduction

In this page you can find the example usage for java.awt.event KeyEvent isMetaDown.

Prototype

public boolean isMetaDown() 

Source Link

Document

Returns whether or not the Meta modifier is down on this event.

Usage

From source file:com.frostwire.gui.library.LibraryUtils.java

public static boolean isRefreshKeyEvent(KeyEvent e) {
    int keyCode = e.getKeyCode();
    boolean ctrlCmdDown = e.isControlDown() || e.isAltGraphDown() || e.isMetaDown();
    return keyCode == KeyEvent.VK_F5 || (ctrlCmdDown && keyCode == KeyEvent.VK_R);
}

From source file:Main.java

private void displayInfo(KeyEvent e, String keyStatus) {

    // You should only rely on the key char if the event
    // is a key typed event.
    int id = e.getID();
    String keyString;/*www  .  j  av a2  s.  c o  m*/
    if (id == KeyEvent.KEY_TYPED) {
        char c = e.getKeyChar();
        keyString = "key character = '" + c + "'";
    } else {
        int keyCode = e.getKeyCode();
        keyString = "key code = " + keyCode + " (" + KeyEvent.getKeyText(keyCode) + ")";
    }

    int modifiersEx = e.getModifiersEx();
    String modString = "extended modifiers = " + modifiersEx;
    String tmpString = KeyEvent.getModifiersExText(modifiersEx);
    System.out.println(e.isMetaDown());

    if (tmpString.length() > 0) {
        modString += " (" + tmpString + ")";
    } else {
        modString += " (no extended modifiers)";
    }

    String actionString = "action key? ";
    if (e.isActionKey()) {
        actionString += "YES";
    } else {
        actionString += "NO";
    }

    String locationString = "key location: ";
    int location = e.getKeyLocation();
    if (location == KeyEvent.KEY_LOCATION_STANDARD) {
        locationString += "standard";
    } else if (location == KeyEvent.KEY_LOCATION_LEFT) {
        locationString += "left";
    } else if (location == KeyEvent.KEY_LOCATION_RIGHT) {
        locationString += "right";
    } else if (location == KeyEvent.KEY_LOCATION_NUMPAD) {
        locationString += "numpad";
    } else { // (location == KeyEvent.KEY_LOCATION_UNKNOWN)
        locationString += "unknown";
    }

    displayArea.append(keyStatus + newline + "    " + keyString + newline + "    " + modString + newline
            + "    " + actionString + newline + "    " + locationString + newline);
    displayArea.setCaretPosition(displayArea.getDocument().getLength());
}

From source file:com.igormaznitsa.mindmap.swing.panel.MindMapPanel.java

public MindMapPanel(final MindMapPanelController controller) {
    super(null);/*from ww w  .j a  v  a 2  s .c  o m*/
    this.textEditorPanel.setLayout(new BorderLayout(0, 0));
    this.controller = controller;

    this.config = new MindMapPanelConfig(controller.provideConfigForMindMapPanel(this), false);

    this.textEditor.setMargin(new Insets(5, 5, 5, 5));
    this.textEditor.setBorder(BorderFactory.createEtchedBorder());
    this.textEditor.setTabSize(4);
    this.textEditor.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(final KeyEvent e) {
            switch (e.getKeyCode()) {
            case KeyEvent.VK_ENTER: {
                e.consume();
            }
                break;
            case KeyEvent.VK_TAB: {
                if ((e.getModifiers() & ALL_SUPPORTED_MODIFIERS) == 0) {
                    e.consume();
                    final Topic edited = elementUnderEdit.getModel();
                    final int[] topicPosition = edited.getPositionPath();
                    endEdit(true);
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            final Topic theTopic = model.findForPositionPath(topicPosition);
                            if (theTopic != null) {
                                makeNewChildAndStartEdit(theTopic, null);
                            }
                        }
                    });
                }
            }
                break;
            default:
                break;
            }
        }

        @Override
        public void keyTyped(final KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ENTER) {
                if ((e.getModifiers() & ALL_SUPPORTED_MODIFIERS) == 0) {
                    e.consume();
                    endEdit(true);
                } else {
                    e.consume();
                    textEditor.insert("\n", textEditor.getCaretPosition()); //NOI18N
                }
            }
        }

        @Override
        public void keyReleased(final KeyEvent e) {
            if (config.isKeyEvent(MindMapPanelConfig.KEY_CANCEL_EDIT, e)) {
                e.consume();
                final Topic edited = elementUnderEdit == null ? null : elementUnderEdit.getModel();
                endEdit(false);
                if (edited != null && edited.canBeLost()) {
                    deleteTopics(edited);
                    if (pathToPrevTopicBeforeEdit != null) {
                        final int[] path = pathToPrevTopicBeforeEdit;
                        pathToPrevTopicBeforeEdit = null;
                        SwingUtilities.invokeLater(new Runnable() {
                            @Override
                            public void run() {
                                final Topic topic = model.findForPositionPath(path);
                                if (topic != null) {
                                    select(topic, false);
                                }
                            }
                        });
                    }
                }
            }
        }
    });

    this.textEditor.getDocument().addDocumentListener(new DocumentListener() {

        private void updateEditorPanelSize(final Dimension newSize) {
            final Dimension editorPanelMinSize = textEditorPanel.getMinimumSize();
            final Dimension newDimension = new Dimension(Math.max(editorPanelMinSize.width, newSize.width),
                    Math.max(editorPanelMinSize.height, newSize.height));
            textEditorPanel.setSize(newDimension);
            textEditorPanel.repaint();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            updateEditorPanelSize(textEditor.getPreferredSize());
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            updateEditorPanelSize(textEditor.getPreferredSize());
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            updateEditorPanelSize(textEditor.getPreferredSize());
        }
    });
    this.textEditorPanel.add(this.textEditor, BorderLayout.CENTER);

    super.setOpaque(true);

    final KeyAdapter keyAdapter = new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            if (config.isKeyEvent(MindMapPanelConfig.KEY_ADD_CHILD_AND_START_EDIT, e)) {
                if (!selectedTopics.isEmpty()) {
                    makeNewChildAndStartEdit(selectedTopics.get(0), null);
                }
            } else if (config.isKeyEvent(MindMapPanelConfig.KEY_ADD_SIBLING_AND_START_EDIT, e)) {
                if (!hasActiveEditor() && hasOnlyTopicSelected()) {
                    final Topic baseTopic = selectedTopics.get(0);
                    makeNewChildAndStartEdit(baseTopic.getParent() == null ? baseTopic : baseTopic.getParent(),
                            baseTopic);
                }
            } else if (config.isKeyEvent(MindMapPanelConfig.KEY_FOCUS_ROOT_OR_START_EDIT, e)) {
                if (!hasSelectedTopics()) {
                    select(getModel().getRoot(), false);
                } else if (hasOnlyTopicSelected()) {
                    startEdit((AbstractElement) selectedTopics.get(0).getPayload());
                }
            }
        }

        @Override
        public void keyReleased(final KeyEvent e) {
            if (config.isKeyEvent(MindMapPanelConfig.KEY_DELETE_TOPIC, e)) {
                e.consume();
                deleteSelectedTopics();
            } else if (config.isKeyEventDetected(e, MindMapPanelConfig.KEY_FOCUS_MOVE_LEFT,
                    MindMapPanelConfig.KEY_FOCUS_MOVE_RIGHT, MindMapPanelConfig.KEY_FOCUS_MOVE_UP,
                    MindMapPanelConfig.KEY_FOCUS_MOVE_DOWN)) {
                e.consume();
                processMoveFocusByKey(e);
            }
        }
    };

    this.setFocusTraversalKeysEnabled(false);

    final MindMapPanel theInstance = this;

    final MouseAdapter adapter = new MouseAdapter() {

        @Override
        public void mouseEntered(final MouseEvent e) {
            setCursor(Cursor.getDefaultCursor());
        }

        @Override
        public void mouseMoved(final MouseEvent e) {
            if (!controller.isMouseMoveProcessingAllowed(theInstance)) {
                return;
            }
            final AbstractElement element = findTopicUnderPoint(e.getPoint());
            if (element == null) {
                setCursor(Cursor.getDefaultCursor());
                setToolTipText(null);
            } else {
                final ElementPart part = element.findPartForPoint(e.getPoint());
                setCursor(part == ElementPart.ICONS || part == ElementPart.COLLAPSATOR
                        ? Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)
                        : Cursor.getDefaultCursor());
                if (part == ElementPart.ICONS) {
                    final Extra<?> extra = element.getIconBlock().findExtraForPoint(
                            e.getPoint().getX() - element.getBounds().getX(),
                            e.getPoint().getY() - element.getBounds().getY());
                    if (extra != null) {
                        setToolTipText(makeHtmlTooltipForExtra(extra));
                    } else {
                        setToolTipText(null);
                    }
                } else {
                    setToolTipText(null);
                }
            }
        }

        @Override
        public void mousePressed(final MouseEvent e) {
            if (!controller.isMouseClickProcessingAllowed(theInstance)) {
                return;
            }
            try {
                if (e.isPopupTrigger()) {
                    mouseDragSelection = null;
                    MindMap theMap = model;
                    AbstractElement element = null;
                    if (theMap != null) {
                        element = findTopicUnderPoint(e.getPoint());
                    }
                    processPopUp(e.getPoint(), element);
                    e.consume();
                } else {
                    endEdit(elementUnderEdit != null);
                    mouseDragSelection = null;
                }
            } catch (Exception ex) {
                LOGGER.error("Error during mousePressed()", ex);
            }
        }

        @Override
        public void mouseReleased(final MouseEvent e) {
            if (!controller.isMouseClickProcessingAllowed(theInstance)) {
                return;
            }
            try {
                if (draggedElement != null) {
                    draggedElement.updatePosition(e.getPoint());
                    if (endDragOfElement(draggedElement, destinationElement)) {
                        updateView(true);
                    }
                } else if (mouseDragSelection != null) {
                    final List<Topic> covered = mouseDragSelection.getAllSelectedElements(model);
                    if (e.isShiftDown()) {
                        for (final Topic m : covered) {
                            select(m, false);
                        }
                    } else if (e.isControlDown()) {
                        for (final Topic m : covered) {
                            select(m, true);
                        }
                    } else {
                        removeAllSelection();
                        for (final Topic m : covered) {
                            select(m, false);
                        }
                    }
                } else if (e.isPopupTrigger()) {
                    mouseDragSelection = null;
                    MindMap theMap = model;
                    AbstractElement element = null;
                    if (theMap != null) {
                        element = findTopicUnderPoint(e.getPoint());
                    }
                    processPopUp(e.getPoint(), element);
                    e.consume();
                }
            } catch (Exception ex) {
                LOGGER.error("Error during mouseReleased()", ex);
            } finally {
                mouseDragSelection = null;
                draggedElement = null;
                destinationElement = null;
                repaint();
            }
        }

        @Override
        public void mouseDragged(final MouseEvent e) {
            if (!controller.isMouseMoveProcessingAllowed(theInstance)) {
                return;
            }
            scrollRectToVisible(new Rectangle(e.getX(), e.getY(), 1, 1));

            if (!popupMenuActive) {
                if (draggedElement == null && mouseDragSelection == null) {
                    final AbstractElement elementUnderMouse = findTopicUnderPoint(e.getPoint());
                    if (elementUnderMouse == null) {
                        MindMap theMap = model;
                        if (theMap != null) {
                            final AbstractElement element = findTopicUnderPoint(e.getPoint());
                            if (controller.isSelectionAllowed(theInstance) && element == null) {
                                mouseDragSelection = new MouseSelectedArea(e.getPoint());
                            }
                        }
                    } else if (controller.isElementDragAllowed(theInstance)) {
                        if (elementUnderMouse.isMoveable()) {
                            selectedTopics.clear();

                            final Point mouseOffset = new Point(
                                    (int) Math
                                            .round(e.getPoint().getX() - elementUnderMouse.getBounds().getX()),
                                    (int) Math
                                            .round(e.getPoint().getY() - elementUnderMouse.getBounds().getY()));
                            draggedElement = new DraggedElement(elementUnderMouse, config, mouseOffset,
                                    e.isControlDown() || e.isMetaDown() ? DraggedElement.Modifier.MAKE_JUMP
                                            : DraggedElement.Modifier.NONE);
                            draggedElement.updatePosition(e.getPoint());
                            findDestinationElementForDragged();
                        } else {
                            draggedElement = null;
                        }
                        repaint();
                    }
                } else if (mouseDragSelection != null) {
                    if (controller.isSelectionAllowed(theInstance)) {
                        mouseDragSelection.update(e);
                    } else {
                        mouseDragSelection = null;
                    }
                    repaint();
                } else if (draggedElement != null) {
                    if (controller.isElementDragAllowed(theInstance)) {
                        draggedElement.updatePosition(e.getPoint());
                        findDestinationElementForDragged();
                    } else {
                        draggedElement = null;
                    }
                    repaint();
                }
            } else {
                mouseDragSelection = null;
            }
        }

        @Override
        public void mouseWheelMoved(final MouseWheelEvent e) {
            if (controller.isMouseWheelProcessingAllowed(theInstance)) {
                mouseDragSelection = null;
                draggedElement = null;

                final MindMapPanelConfig theConfig = config;

                if (!e.isConsumed() && (theConfig != null
                        && ((e.getModifiers() & theConfig.getScaleModifiers()) == theConfig
                                .getScaleModifiers()))) {
                    endEdit(elementUnderEdit != null);

                    setScale(
                            Math.max(0.3d, Math.min(getScale() + (SCALE_STEP * -e.getWheelRotation()), 10.0d)));

                    updateView(false);
                    e.consume();
                } else {
                    sendToParent(e);
                }
            }
        }

        @Override
        public void mouseClicked(final MouseEvent e) {
            if (!controller.isMouseClickProcessingAllowed(theInstance)) {
                return;
            }
            mouseDragSelection = null;
            draggedElement = null;

            MindMap theMap = model;
            AbstractElement element = null;
            if (theMap != null) {
                element = findTopicUnderPoint(e.getPoint());
            }

            if (element != null) {
                final ElementPart part = element.findPartForPoint(e.getPoint());
                if (part == ElementPart.COLLAPSATOR) {
                    removeAllSelection();

                    if (element.isCollapsed()) {
                        ((AbstractCollapsableElement) element).setCollapse(false);
                        if ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
                            ((AbstractCollapsableElement) element).collapseAllFirstLevelChildren();
                        }
                    } else {
                        ((AbstractCollapsableElement) element).setCollapse(true);
                    }
                    invalidate();
                    fireNotificationMindMapChanged();
                    repaint();
                } else if (part != ElementPart.ICONS && e.getClickCount() > 1) {
                    startEdit(element);
                } else if (part == ElementPart.ICONS) {
                    final Extra<?> extra = element.getIconBlock().findExtraForPoint(
                            e.getPoint().getX() - element.getBounds().getX(),
                            e.getPoint().getY() - element.getBounds().getY());
                    if (extra != null) {
                        fireNotificationClickOnExtra(element.getModel(), e.getClickCount(), extra);
                    }
                } else {
                    if (!e.isControlDown()) {
                        // only
                        removeAllSelection();
                        select(element.getModel(), false);
                    } else // group
                    if (selectedTopics.isEmpty()) {
                        select(element.getModel(), false);
                    } else {
                        select(element.getModel(), true);
                    }
                }
            }
        }
    };

    addMouseWheelListener(adapter);
    addMouseListener(adapter);
    addMouseMotionListener(adapter);
    addKeyListener(keyAdapter);

    this.textEditorPanel.setVisible(false);
    this.add(this.textEditorPanel);
}

From source file:tax.MainForm.java

private void dateTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dateTextKeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        if (!dateText.getText().equals("")) {
            Util.fadeInAndOut(dateText, Util.darkGreen);

            priceText.setEnabled(true);/*from  ww w  .  j  av a 2  s . c  o m*/
            priceText.requestFocus();
        } else
            Util.fadeInAndOut(dateText, Util.darkOrange);
    } else if (!evt.isActionKey() && !evt.isAltDown() && !evt.isControlDown() && !evt.isShiftDown()
            && !evt.isMetaDown() && (evt.getKeyCode() != KeyEvent.VK_BACK_SPACE)
            && (evt.getKeyCode() != KeyEvent.VK_DELETE) && (evt.getKeyCode() != KeyEvent.VK_ESCAPE)) {
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                String text = dateText.getText();
                int dateLength = text.length();

                while (lastDateTextLength == dateLength) {
                    try {
                        Thread.sleep(100);
                        System.out.println("text: " + text);
                        System.out.println(lastDateTextLength + " " + dateLength);
                        return;
                    } catch (InterruptedException ex) {
                        Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    text = dateText.getText();
                    dateLength = text.length();
                }
                try {
                    int num = Integer.decode(text);
                    if (num > 31) {
                        if (text.length() > 0)
                            dateText.setText(text.substring(0, dateLength - 1));
                        else
                            dateText.setText("");
                        return;
                    }
                } catch (Exception e) {
                    if (text.length() > 0)
                        dateText.setText(text.substring(0, dateLength - 1));
                    else
                        dateText.setText("");
                    return;
                }
                lastDateTextLength = dateLength;
            }
        });
    }
}

From source file:tax.MainForm.java

private void priceTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_priceTextKeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        if (!priceText.getText().equals("")) {
            Util.fadeInAndOut(priceText, Util.darkGreen);

            afmText.setEnabled(true);//from www  . j  a  va 2  s .  com
            afmText.requestFocus();
        } else
            Util.fadeInAndOut(priceText, Util.darkOrange);
    } else if (!evt.isActionKey() && !evt.isAltDown() && !evt.isControlDown() && !evt.isShiftDown()
            && !evt.isMetaDown() && (evt.getKeyCode() != KeyEvent.VK_BACK_SPACE)
            && (evt.getKeyCode() != KeyEvent.VK_DELETE) && (evt.getKeyCode() != KeyEvent.VK_ESCAPE)) {
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                String text = priceText.getText();
                int priceLength = text.length();

                while (lastPriceTextLength == priceLength) {
                    try {
                        Thread.sleep(100);
                        System.out.println("text: " + text);
                        System.out.println(lastPriceTextLength + " " + priceLength);
                        return;
                    } catch (InterruptedException ex) {
                        Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    text = priceText.getText();
                    priceLength = text.length();
                }

                //                    if (text.charAt(priceLength - 1) == '\u002c')
                //                        priceText.setText(text.substring(0, priceLength - 1) + ".");

                try {
                    Double.parseDouble(text);
                } catch (Exception e) {
                    if (text.length() > 0) {
                        //                            System.out.println(text.charAt(priceLength - 1));
                        priceText.setText(text.substring(0, priceLength - 1));
                    } else
                        priceText.setText("");
                    return;
                }
                lastPriceTextLength = priceLength;
            }

        });
    }
}

From source file:tax.MainForm.java

private void afmTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_afmTextKeyPressed
    String text = afmText.getText();

    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        if (text.length() == 9) {

            for (Object key : afmToName.keySet()) {
                if (afmToName.get(key).equals(text))
                    nameText.setText(key.toString());
            }//from  w  ww  .ja va2 s . c o  m

            //                Util.fadeInAndOut(afmText, Util.darkGreen);
            addRowBut.doClick();
        } else if (text.length() == 0) {
            Util.fadeInAndOut(afmText, Color.white);
            nameText.setEnabled(true);
            nameText.requestFocus();
        } else
            Util.fadeInAndOut(afmText, Util.darkOrange);
    } else if (!evt.isActionKey() && !evt.isAltDown() && !evt.isControlDown() && !evt.isShiftDown()
            && !evt.isMetaDown() && (evt.getKeyCode() != KeyEvent.VK_BACK_SPACE)
            && (evt.getKeyCode() != KeyEvent.VK_DELETE) && (evt.getKeyCode() != KeyEvent.VK_ESCAPE)) {
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                String text = afmText.getText();
                int afmLength = text.length();

                while (lastAFMTextLength == afmLength) {
                    try {
                        Thread.sleep(100);
                        System.out.println("text: " + text);
                        System.out.println(lastAFMTextLength + " " + afmLength);
                        return;
                    } catch (InterruptedException ex) {
                        Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    text = afmText.getText();
                    afmLength = text.length();
                }

                try {
                    int num = Integer.decode(text);
                    if (afmLength > 9) {
                        if (text.length() > 0)
                            afmText.setText(text.substring(0, afmLength - 1));
                        else
                            afmText.setText("");
                        return;
                    }
                } catch (Exception e) {
                    if (text.length() > 0)
                        afmText.setText(text.substring(0, afmLength - 1));
                    else
                        afmText.setText("");
                    return;
                }

                lastAFMTextLength = afmLength;
            }
        });
    }
}

From source file:tax.MainForm.java

private void afmTextSKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_afmTextSKeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        String text = afmTextS.getText();

        if (text.length() == 9) {
            try {
                int num = Integer.parseInt(text);
            } catch (Exception e) {
                afmTextS.setText("");
                return;
            }//from  w ww  .  j  a v a 2s.c  om

            //                Util.fadeInAndOut(afmTextS, Util.darkGreen);
            addNameBut.doClick();
        } else {
            Util.fadeInAndOut(afmTextS, Util.darkOrange);
        }
    } else if (!evt.isActionKey() && !evt.isAltDown() && !evt.isControlDown() && !evt.isShiftDown()
            && !evt.isMetaDown() && (evt.getKeyCode() != KeyEvent.VK_BACK_SPACE)
            && (evt.getKeyCode() != KeyEvent.VK_DELETE) && (evt.getKeyCode() != KeyEvent.VK_ESCAPE)) {
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                String text = afmTextS.getText();
                int afmLength = text.length();

                while (lastAFMTextSLength == afmLength) {
                    try {
                        Thread.sleep(100);
                        System.out.println("text: " + text);
                        System.out.println(lastAFMTextSLength + " " + afmLength);
                        return;
                    } catch (InterruptedException ex) {
                        Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    text = afmTextS.getText();
                    afmLength = text.length();
                }

                try {
                    int num = Integer.decode(text);
                    if (afmLength > 9) {
                        if (text.length() > 0)
                            afmTextS.setText(text.substring(0, afmLength - 1));
                        else
                            afmTextS.setText("");
                        return;
                    }
                } catch (Exception e) {
                    if (text.length() > 0)
                        afmTextS.setText(text.substring(0, afmLength - 1));
                    else
                        afmTextS.setText("");
                    return;
                }

                lastAFMTextSLength = afmLength;
            }
        });
    }
}

From source file:tufts.vue.RichTextBox.java

public void keyPressed(KeyEvent e) {
    if (DEBUG.KEYS)
        out(e.toString());//from   www  . j  a va2s .  c  o  m
    //System.out.println("TextBox: " + e);

    //if (VueUtil.isAbortKey(e)) // check for ESCAPE for CTRL-Z or OPTION-Z if on mac
    if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
        e.consume();

        //     System.out.println(mUnchangedText);
        //setText(mUnchangedText);
        revert = true;
        getParent().remove(this); // will trigger a save (via focusLost)
        return;
        // setSize(mUnchangedSize); // todo: won't be good enough if we ever resize the actual node as we type
    } else if (isFinishEditKeyPress(e)) {
        keyWasPressed = true;
        e.consume();
        getParent().remove(this); // will trigger a save (via focusLost)
        VUE.getFormattingPanel().getTextPropsPane().getFontEditorPanel().updateFormatControlsTB(this);
    } else if (e.getKeyCode() == KeyEvent.VK_U && e.isMetaDown()) {
        e.consume();
        String t = getText();
        if (e.isShiftDown())
            setText(t.toUpperCase()); // upper whole string
        else
            setText(Character.toTitleCase(t.charAt(0)) + t.substring(1)); // upper first char
    } else
        keyWasPressed = true;

    // Dimension d = preAddDimension;
    // d.height = this.getPreferredSize().height;
    // setSize(getPreferredSize());

    // action keys will be ignored if we consume this here!
    // (e.g., "enter" does nothing)
    //e.consume();   
}