Ticket #1589: JosmAction.diff

File JosmAction.diff, 1.7 KB (added by Henry Loenwind, 16 years ago)
  • src/org/openstreetmap/josm/actions/JosmAction.java

     
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    22package org.openstreetmap.josm.actions;
    33
     4import java.awt.event.InputEvent;
    45
    56import javax.swing.AbstractAction;
    67import javax.swing.JComponent;
     
    2829        public JosmAction(String name, String iconName, String tooltip, int shortCut, int modifier, boolean register) {
    2930                super(name, iconName == null ? null : ImageProvider.get(iconName));
    3031                setHelpId();
     32                if (Main.withOSXIntegration) {
     33                        // actually using Event.CTRL_MASK is wrong, we should use
     34                        // Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()
     35                        // instead. But I don't want to change too many files, so
     36                        // just swap CTRL and META when on OSX...
     37                        if ((modifier & InputEvent.CTRL_MASK) != 0) {
     38                                modifier = (modifier & ~ InputEvent.CTRL_MASK) | InputEvent.META_MASK;
     39                        } else if ((modifier & InputEvent.META_MASK) != 0) {
     40                                modifier = (modifier & ~ InputEvent.META_MASK) | InputEvent.CTRL_MASK;
     41                        } else if ((modifier & InputEvent.CTRL_DOWN_MASK) != 0) {
     42                                modifier = (modifier & ~ InputEvent.CTRL_DOWN_MASK) | InputEvent.META_DOWN_MASK;
     43                        } else if ((modifier & InputEvent.META_DOWN_MASK) != 0) {
     44                                modifier = (modifier & ~ InputEvent.META_DOWN_MASK) | InputEvent.CTRL_DOWN_MASK;
     45                        }
     46                }
    3147                String scl = ShortCutLabel.name(shortCut, modifier);
    3248                putValue(SHORT_DESCRIPTION, "<html>"+tooltip+" <font size='-2'>"+scl+"</font>"+(scl.equals("")?"":"&nbsp;")+"</html>");
    3349                if (shortCut != 0) {