Changeset 4418 in josm


Ignore:
Timestamp:
2011-09-13T10:26:37+02:00 (13 years ago)
Author:
simon04
Message:

fix #6815 - copy coordinates as keyboard shortcut. JavaDoc for Shortcut class.

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/CopyCoordinatesAction.java

    r4381 r4418  
    44
    55import java.awt.event.ActionEvent;
     6import java.awt.event.KeyEvent;
    67import java.util.Collection;
    78import java.util.Collections;
    89import org.openstreetmap.josm.data.osm.Node;
    910import org.openstreetmap.josm.data.osm.OsmPrimitive;
     11import org.openstreetmap.josm.tools.Shortcut;
    1012import org.openstreetmap.josm.tools.Utils;
    1113
     
    1416    public CopyCoordinatesAction() {
    1517        super(tr("Copy Coordinates"), null,
    16                 tr("Copy coordinates of selected nodes to clipboard."), null, false);
     18                tr("Copy coordinates of selected nodes to clipboard."),
     19                Shortcut.registerShortcut("copy:coordinates", tr("Edit: {0}", tr("Copy Coordinates")), KeyEvent.VK_C, Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT),
     20                false);
    1721        putValue("toolbar", "copy/coordinates");
    1822    }
  • trunk/src/org/openstreetmap/josm/tools/Shortcut.java

    r3490 r4418  
    22package org.openstreetmap.josm.tools;
    33
     4import java.awt.Menu;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    56
     
    2526 *       finally manages loading and saving shortcuts to/from the preferences.
    2627 *
    27  * Action authors: You only need the registerShortcut() factory. Ignore everything
     28 * Action authors: You only need the {@see #registerShortcut} factory. Ignore everything
    2829 *                 else.
    2930 *
     
    256257
    257258    // use these constants to request shortcuts
    258     public static final int GROUP_NONE = 0;          // no shortcut
    259     public static final int GROUP_HOTKEY = 1;        // a button action, will use another modifier than MENU on system with a meta key
    260     public static final int GROUP_MENU = 2;          // a menu action, e.g. "ctrl-e"/"cmd-e" (export)
    261     public static final int GROUP_EDIT = 3;          // direct edit key, e.g. "a" (add)
    262     public static final int GROUP_LAYER = 4;         // toggle one of the right-hand-side windows, e.g. "alt-l" (layers)
    263     public static final int GROUP_DIRECT = 5;        // for non-letter keys, preferable without modifier, e.g. F5
    264     public static final int GROUP_MNEMONIC = 6;      // for use with Menu.setMnemonic() only!
     259    /**
     260     * no shortcut.
     261     */
     262    public static final int GROUP_NONE = 0;
     263    /**
     264     * a button action, will use another modifier than MENU on system with a meta key.
     265     */
     266    public static final int GROUP_HOTKEY = 1;
     267    /**
     268     * a menu action, e.g. "ctrl-e" (export).
     269     */
     270    public static final int GROUP_MENU = 2;
     271    /**
     272     * direct edit key, e.g. "a" (add).
     273     */
     274    public static final int GROUP_EDIT = 3;
     275    /**
     276     * toggle one of the right-hand-side windows, e.g. "alt-l" (layers).
     277     */
     278    public static final int GROUP_LAYER = 4;
     279    /**
     280     * for non-letter keys, preferable without modifier, e.g. F5.
     281     */
     282    public static final int GROUP_DIRECT = 5;
     283    /**
     284     * for use with {@see #setMnemonic} only!
     285     */
     286    public static final int GROUP_MNEMONIC = 6;
    265287    public static final int GROUP__MAX = 7;
    266288    public static final int GROUP_RESERVED = 1000;
     
    375397     * Here you get your shortcuts from. The parameters are:
    376398     *
    377      * shortText - an ID. re-use a "system:*" ID if possible, else use something unique.
    378      *             "menu:*" is reserved for menu mnemonics, "core:*" is reserved for
    379      *             actions that are part of JOSM's core. Use something like
    380      *             <pluginname>+":"+<actionname>
    381      * longText - this will be displayed in the shortcut preferences dialog. Better
    382      *            use soomething the user will recognize...
    383      * requestedKey - the key you'd prefer. Use a KeyEvent.VK_* constant here.
    384      * requestedGroup - the group this shortcut fits best. This will determine the
    385      *                  modifiers your shortcut will get assigned. Use the GROUP_*
    386      *                  constants defined above.
     399     * @param shortText an ID. re-use a {@code "system:*"} ID if possible, else use something unique.
     400     * {@code "menu:*"} is reserved for menu mnemonics, {@code "core:*"} is reserved for
     401     * actions that are part of JOSM's core. Use something like
     402     * {@code <pluginname>+":"+<actionname>}.
     403     * @param longText this will be displayed in the shortcut preferences dialog. Better
     404     * use something the user will recognize...
     405     * @param requestedKey the key you'd prefer. Use a {@link KeyEvent KeyEvent.VK_*} constant here.
     406     * @param requestedGroup the group this shortcut fits best. This will determine the
     407     * modifiers your shortcut will get assigned. Use the {@code GROUP_*}
     408     * constants defined above.
     409     * @param modifier to register a {@code ctrl+shift} command, use {@see #SHIFT_DEFAULT}.
    387410     */
    388411    public static Shortcut registerShortcut(String shortText, String longText, int requestedKey, int requestedGroup, int modifier) {
    389412        return registerShortcut(shortText, longText, requestedKey, requestedGroup, modifier, null);
    390413    }
     414
     415    /**
     416     * Register a shortcut.
     417     *
     418     * Here you get your shortcuts from. The parameters are:
     419     *
     420     * @param shortText an ID. re-use a {@code "system:*"} ID if possible, else use something unique.
     421     * {@code "menu:*"} is reserved for menu mnemonics, {@code "core:*"} is reserved for
     422     * actions that are part of JOSM's core. Use something like
     423     * {@code <pluginname>+":"+<actionname>}.
     424     * @param longText this will be displayed in the shortcut preferences dialog. Better
     425     * use something the user will recognize...
     426     * @param requestedKey the key you'd prefer. Use a {@link KeyEvent KeyEvent.VK_*} constant here.
     427     * @param requestedGroup the group this shortcut fits best. This will determine the
     428     * modifiers your shortcut will get assigned. Use the {@code GROUP_*}
     429     * constants defined above.
     430     */
    391431    public static Shortcut registerShortcut(String shortText, String longText, int requestedKey, int requestedGroup) {
    392432        return registerShortcut(shortText, longText, requestedKey, requestedGroup, null, null);
Note: See TracChangeset for help on using the changeset viewer.