Changeset 12526 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2017-07-27T19:08:53+02:00 (7 years ago)
Author:
Don-vip
Message:

see #11924 - fix last warnings about extended modifiers

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

Legend:

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

    r12517 r12526  
    142142        }
    143143
    144         updateKeyModifiers(e.getModifiers());
     144        updateKeyModifiers(e);
    145145
    146146        Command c;
     
    295295        Main.map.mapView.requestFocus();
    296296
    297         Command c = buildDeleteCommands(e, e.getModifiers(), false);
     297        Command c = buildDeleteCommands(e, e.getModifiersEx(), false);
    298298        if (c != null) {
    299299            Main.main.undoRedo.add(c);
  • trunk/src/org/openstreetmap/josm/actions/mapmode/MapMode.java

    r12518 r12526  
    150150    }
    151151
     152    /**
     153     * Update internal ctrl, alt, shift mask from given input event.
     154     * @param e input event
     155     */
    152156    protected void updateKeyModifiers(InputEvent e) {
    153157        updateKeyModifiersEx(e.getModifiersEx());
    154158    }
    155159
     160    /**
     161     * Update internal ctrl, alt, shift mask from given mouse event.
     162     * @param e mouse event
     163     */
    156164    protected void updateKeyModifiers(MouseEvent e) {
    157165        updateKeyModifiersEx(e.getModifiersEx());
     166    }
     167
     168    /**
     169     * Update internal ctrl, alt, shift mask from given action event.
     170     * @param e action event
     171     * @since 12526
     172     */
     173    protected void updateKeyModifiers(ActionEvent e) {
     174        // ActionEvent does not have a getModifiersEx() method like other events :(
     175        updateKeyModifiersEx(mapOldModifiers(e.getModifiers()));
    158176    }
    159177
     
    181199    }
    182200
     201    /**
     202     * Map old (pre jdk 1.4) modifiers to extended modifiers (only for Ctrl, Alt, Shift).
     203     * @param modifiers old modifiers
     204     * @return extended modifiers
     205     */
     206    @SuppressWarnings("deprecation")
     207    private static int mapOldModifiers(int modifiers) {
     208        if ((modifiers & InputEvent.CTRL_MASK) != 0) {
     209            modifiers |= InputEvent.CTRL_DOWN_MASK;
     210        }
     211        if ((modifiers & InputEvent.ALT_MASK) != 0) {
     212            modifiers |= InputEvent.ALT_DOWN_MASK;
     213        }
     214        if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
     215            modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
     216        }
     217        if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
     218            modifiers |= InputEvent.SHIFT_DOWN_MASK;
     219        }
     220
     221        return modifiers;
     222    }
     223
    183224    protected void requestFocusInMapView() {
    184225        if (isEnabled()) {
Note: See TracChangeset for help on using the changeset viewer.