Changeset 458 in josm


Ignore:
Timestamp:
2007-11-08T06:32:34+01:00 (16 years ago)
Author:
(none)
Message:

add keyboard shortcuts "1,2,3,4" for the "View/Zoom In ..." menu entries

File:
1 edited

Legend:

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

    r410 r458  
    66
    77import java.awt.event.ActionEvent;
     8import java.awt.event.KeyEvent;
    89import java.util.Collection;
    910
     
    2526        public static final String[] modes = {
    2627                marktr("data"),
     28                marktr("layer"),
    2729                marktr("selection"),
    28                 marktr("layer"),
    2930                marktr("conflict")
    3031        };
    3132        private final String mode;
    3233
     34        private static int getModeShortcut(String mode) {
     35                int shortcut = -1;
     36
     37                if(mode.equals("data")) {
     38                        shortcut = KeyEvent.VK_1;
     39                }       
     40                if(mode.equals("layer")) {
     41                        shortcut = KeyEvent.VK_2;
     42                }
     43                if(mode.equals("selection")) {
     44                        shortcut = KeyEvent.VK_3;
     45                }
     46                if(mode.equals("conflict")) {
     47                        shortcut = KeyEvent.VK_4;
     48                }
     49
     50                return shortcut;
     51        }
     52   
    3353        public AutoScaleAction(String mode) {
    34                 super(tr("Zoom to {0}", mode), "dialogs/autoscale/"+mode, tr("Zoom the view to {0}.", tr(mode)), 0, 0, true);
     54                super(tr("Zoom to {0}", mode), "dialogs/autoscale/"+mode, tr("Zoom the view to {0}.", tr(mode)), AutoScaleAction.getModeShortcut(mode), 0, true);
    3555                String modeHelp = Character.toUpperCase(mode.charAt(0))+mode.substring(1);
    3656                putValue("help", "Action/AutoScale/"+modeHelp);
Note: See TracChangeset for help on using the changeset viewer.