Ignore:
Timestamp:
2018-07-08T00:27:14+02:00 (5 weeks ago)
Author:
Don-vip
Message:

see #16453 - proper support of different keyboard layouts

File:
1 edited

Legend:

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

    r13852 r14012  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.Toolkit;
    67import java.awt.event.KeyEvent;
    78import java.util.ArrayList;
     
    440441
    441442    /**
     443     * Register a shortcut linked to several characters.
     444     *
     445     * @param shortText an ID. re-use a {@code "system:*"} ID if possible, else use something unique.
     446     * {@code "menu:*"} is reserved for menu mnemonics, {@code "core:*"} is reserved for
     447     * actions that are part of JOSM's core. Use something like
     448     * {@code <pluginname>+":"+<actionname>}.
     449     * @param longText this will be displayed in the shortcut preferences dialog. Better
     450     * use something the user will recognize...
     451     * @param characters the characters you'd prefer
     452     * @param requestedGroup the group this shortcut fits best. This will determine the
     453     * modifiers your shortcut will get assigned. Use the constants defined above.
     454     * @return the shortcut
     455     */
     456    public static List<Shortcut> registerMultiShortcuts(String shortText, String longText, List<Character> characters, int requestedGroup) {
     457        List<Shortcut> result = new ArrayList<>();
     458        int i = 1;
     459        Map<Integer, Integer> regularKeyCodes = KeyboardUtils.getRegularKeyCodesMap();
     460        for (Character c : characters) {
     461            Integer code = (int) c;
     462            result.add(registerShortcut(
     463                    new StringBuilder(shortText).append(" (").append(i).append(')').toString(), longText,
     464                    // Add extended keyCode if not a regular one
     465                    regularKeyCodes.containsKey(code) ? regularKeyCodes.get(code) : c | KeyboardUtils.EXTENDED_KEYCODE_FLAG,
     466                    requestedGroup));
     467            i++;
     468        }
     469        return result;
     470    }
     471
     472    /**
    442473     * Register a shortcut.
    443474     *
Note: See TracChangeset for help on using the changeset viewer.