Ticket #1589: JosmAction2.diff
File JosmAction2.diff, 2.0 KB (added by , 16 years ago) |
---|
-
src/org/openstreetmap/josm/actions/JosmAction.java
1 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.actions; 3 3 4 import java.awt.event.InputEvent; 4 5 5 6 import javax.swing.AbstractAction; 6 7 import javax.swing.JComponent; … … 28 29 public JosmAction(String name, String iconName, String tooltip, int shortCut, int modifier, boolean register) { 29 30 super(name, iconName == null ? null : ImageProvider.get(iconName)); 30 31 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 } 31 47 String scl = ShortCutLabel.name(shortCut, modifier); 48 if (Main.withOSXIntegration) { 49 putValue(SHORT_DESCRIPTION, tooltip+(scl.equals("")?"":" ("+scl+")")); // no html as tooltip goes native 50 } else { 32 51 putValue(SHORT_DESCRIPTION, "<html>"+tooltip+" <font size='-2'>"+scl+"</font>"+(scl.equals("")?"":" ")+"</html>"); 52 } 33 53 if (shortCut != 0) { 34 54 this.shortCut = KeyStroke.getKeyStroke(shortCut, modifier); 35 55 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(this.shortCut, name);