Ignore:
Timestamp:
2014-09-15T19:42:31+02:00 (10 years ago)
Author:
Don-vip
Message:

fix #5957, fix #10458, see #10455: fix various focus/shortcuts issues:

  • proper use of "Command" modifier on OS X instead of "Ctrl"
  • fix related focus issue on OS X in layer list dialog (copy/paste between layers not working)
  • fix non-working commands after a layer selection: Ctrl-A, Tab, Ctrl-Down/Up/Left/Right, F8
  • fix impossibility to use 'A', 'S' or 'X' keys in relation filter or when renaming layer
Location:
trunk/src/org/openstreetmap/josm/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/InputMapUtils.java

    r7509 r7539  
    1313
    1414/**
    15  * Tools to work with Swing InputMap
    16  *
     15 * Tools to work with Swing InputMap.
     16 * @since 5200
    1717 */
    1818public final class InputMapUtils {
     
    6262
    6363    /**
    64      * Enable activating button on Enter (which is replaced with spacebar for certain Look-And-Feels)
     64     * Enable activating button on Enter (which is replaced with spacebar for certain Look-And-Feels).
     65     * @param b Button
    6566     */
    6667    public static void enableEnter(JButton b) {
    6768         b.setFocusable(true);
    6869         b.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enter");
    69          b.getActionMap().put("enter",b.getAction());
     70         b.getActionMap().put("enter", b.getAction());
    7071    }
    7172
     73    /**
     74     * Add an action activated with Enter key on a component.
     75     * @param c The Swing component
     76     * @param a action activated with Enter key
     77     */
    7278    public static void addEnterAction(JComponent c, Action a) {
    7379         c.getActionMap().put("enter", a);
     
    7581    }
    7682
     83    /**
     84     * Add an action activated with Spacebar key on a component.
     85     * @param c The Swing component
     86     * @param a action activated with Spacebar key
     87     */
    7788    public static void addSpacebarAction(JComponent c, Action a) {
    7889         c.getActionMap().put("spacebar", a);
  • trunk/src/org/openstreetmap/josm/tools/Shortcut.java

    r7012 r7539  
    1919
    2020import org.openstreetmap.josm.Main;
     21import org.openstreetmap.josm.gui.util.GuiHelper;
    2122
    2223/**
     
    2728 *       finally manages loading and saving shortcuts to/from the preferences.
    2829 *
    29  * Action authors: You only need the {@link #registerShortcut} factory. Ignore everything
    30  *                 else.
     30 * Action authors: You only need the {@link #registerShortcut} factory. Ignore everything else.
    3131 *
    3232 * All: Use only public methods that are also marked to be used. The others are
    3333 *      public so the shortcut preferences can use them.
    34  *
     34 * @since 1084
    3535 */
    3636public final class Shortcut {
     
    262262    }
    263263
     264    /** None group: used with KeyEvent.CHAR_UNDEFINED if no shortcut is defined */
    264265    public static final int NONE = 5000;
    265266    public static final int MNEMONIC = 5001;
     267    /** Reserved group: for system shortcuts only */
    266268    public static final int RESERVED = 5002;
     269    /** Direct group: no modifier */
    267270    public static final int DIRECT = 5003;
     271    /** Alt group */
    268272    public static final int ALT = 5004;
     273    /** Shift group */
    269274    public static final int SHIFT = 5005;
     275    /** Command group. Matches CTRL modifier on Windows/Linux but META modifier on OS X */
    270276    public static final int CTRL = 5006;
     277    /** Alt-Shift group */
    271278    public static final int ALT_SHIFT = 5007;
     279    /** Alt-Command group. Matches ALT-CTRL modifier on Windows/Linux but ALT-META modifier on OS X */
    272280    public static final int ALT_CTRL = 5008;
     281    /** Command-Shift group. Matches CTRL-SHIFT modifier on Windows/Linux but META-SHIFT modifier on OS X */
    273282    public static final int CTRL_SHIFT = 5009;
     283    /** Alt-Command-Shift group. Matches ALT-CTRL-SHIFT modifier on Windows/Linux but ALT-META-SHIFT modifier on OS X */
    274284    public static final int ALT_CTRL_SHIFT = 5010;
    275285
     
    285295        if (initdone) return;
    286296        initdone = true;
     297        int commandDownMask = GuiHelper.getMenuShortcutKeyMaskEx();
    287298        groups.put(NONE, -1);
    288299        groups.put(MNEMONIC, KeyEvent.ALT_DOWN_MASK);
     
    290301        groups.put(ALT, KeyEvent.ALT_DOWN_MASK);
    291302        groups.put(SHIFT, KeyEvent.SHIFT_DOWN_MASK);
    292         groups.put(CTRL, KeyEvent.CTRL_DOWN_MASK);
     303        groups.put(CTRL, commandDownMask);
    293304        groups.put(ALT_SHIFT, KeyEvent.ALT_DOWN_MASK|KeyEvent.SHIFT_DOWN_MASK);
    294         groups.put(ALT_CTRL, KeyEvent.ALT_DOWN_MASK|KeyEvent.CTRL_DOWN_MASK);
    295         groups.put(CTRL_SHIFT, KeyEvent.CTRL_DOWN_MASK|KeyEvent.SHIFT_DOWN_MASK);
    296         groups.put(ALT_CTRL_SHIFT, KeyEvent.ALT_DOWN_MASK|KeyEvent.CTRL_DOWN_MASK|KeyEvent.SHIFT_DOWN_MASK);
     305        groups.put(ALT_CTRL, KeyEvent.ALT_DOWN_MASK|commandDownMask);
     306        groups.put(CTRL_SHIFT, commandDownMask|KeyEvent.SHIFT_DOWN_MASK);
     307        groups.put(ALT_CTRL_SHIFT, KeyEvent.ALT_DOWN_MASK|commandDownMask|KeyEvent.SHIFT_DOWN_MASK);
    297308
    298309        // (1) System reserved shortcuts
Note: See TracChangeset for help on using the changeset viewer.