Changeset 4418 in josm
- Timestamp:
- 2011-09-13T10:26:37+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CopyCoordinatesAction.java
r4381 r4418 4 4 5 5 import java.awt.event.ActionEvent; 6 import java.awt.event.KeyEvent; 6 7 import java.util.Collection; 7 8 import java.util.Collections; 8 9 import org.openstreetmap.josm.data.osm.Node; 9 10 import org.openstreetmap.josm.data.osm.OsmPrimitive; 11 import org.openstreetmap.josm.tools.Shortcut; 10 12 import org.openstreetmap.josm.tools.Utils; 11 13 … … 14 16 public CopyCoordinatesAction() { 15 17 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); 17 21 putValue("toolbar", "copy/coordinates"); 18 22 } -
trunk/src/org/openstreetmap/josm/tools/Shortcut.java
r3490 r4418 2 2 package org.openstreetmap.josm.tools; 3 3 4 import java.awt.Menu; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 … … 25 26 * finally manages loading and saving shortcuts to/from the preferences. 26 27 * 27 * Action authors: You only need the registerShortcut()factory. Ignore everything28 * Action authors: You only need the {@see #registerShortcut} factory. Ignore everything 28 29 * else. 29 30 * … … 256 257 257 258 // 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; 265 287 public static final int GROUP__MAX = 7; 266 288 public static final int GROUP_RESERVED = 1000; … … 375 397 * Here you get your shortcuts from. The parameters are: 376 398 * 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}. 387 410 */ 388 411 public static Shortcut registerShortcut(String shortText, String longText, int requestedKey, int requestedGroup, int modifier) { 389 412 return registerShortcut(shortText, longText, requestedKey, requestedGroup, modifier, null); 390 413 } 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 */ 391 431 public static Shortcut registerShortcut(String shortText, String longText, int requestedKey, int requestedGroup) { 392 432 return registerShortcut(shortText, longText, requestedKey, requestedGroup, null, null);
Note:
See TracChangeset
for help on using the changeset viewer.