Ignore:
Timestamp:
2017-07-26T23:18:38+02:00 (2 years ago)
Author:
Don-vip
Message:

see #11924 - use extended event modifiers, deprecate old methods - see https://bugs.openjdk.java.net/browse/JDK-8143077

Location:
trunk/src/org/openstreetmap/josm/gui/util
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/util/AdvancedKeyPressDetector.java

    r11386 r12517  
    3535
    3636    private final List<KeyPressReleaseListener> keyListeners = new CopyOnWriteArrayList<>();
     37    @Deprecated
    3738    private final List<ModifierListener> modifierListeners = new CopyOnWriteArrayList<>();
     39    private final List<ModifierExListener> modifierExListeners = new CopyOnWriteArrayList<>();
    3840    private int previousModifiers;
     41    private int previousModifiersEx;
    3942
    4043    private boolean enabled = true;
     
    5154     * Adds an object that wants to receive key modifier changed events.
    5255     * @param l listener to add
    53      */
     56     * @deprecated use {@link #addModifierExListener} instead
     57     */
     58    @Deprecated
    5459    public void addModifierListener(ModifierListener l) {
    5560        modifierListeners.add(l);
     
    5762
    5863    /**
     64     * Adds an object that wants to receive extended key modifier changed events.
     65     * @param l listener to add
     66     * @since 12516
     67     */
     68    public void addModifierExListener(ModifierExListener l) {
     69        modifierExListeners.add(l);
     70    }
     71
     72    /**
    5973     * Removes the listener.
    6074     * @param l listener to remove
     
    6781     * Removes the key modifier listener.
    6882     * @param l listener to remove
    69      */
     83     * @deprecated use {@link #removeModifierExListener} instead
     84     */
     85    @Deprecated
    7086    public void removeModifierListener(ModifierListener l) {
    7187        modifierListeners.remove(l);
     88    }
     89
     90    /**
     91     * Removes the extended key modifier listener.
     92     * @param l listener to remove
     93     * @since 12516
     94     */
     95    public void removeModifierExListener(ModifierExListener l) {
     96        modifierExListeners.remove(l);
    7297    }
    7398
     
    105130        if (!modifierListeners.isEmpty()) {
    106131            Main.warn(tr("Some of the key modifier listeners forgot to remove themselves: {0}"), modifierListeners.toString());
     132        }
     133        if (!modifierExListeners.isEmpty()) {
     134            Main.warn(tr("Some of the key modifier listeners forgot to remove themselves: {0}"), modifierExListeners.toString());
    107135        }
    108136        try {
     
    147175
    148176    @Override
     177    @SuppressWarnings("deprecation")
    149178    public void eventDispatched(AWTEvent e) {
    150179        if (!(e instanceof KeyEvent)) {
     
    162191        }
    163192
     193        // check if ctrl, alt, shift extended modifiers are changed
     194        int modifEx = ke.getModifiersEx();
     195        if (previousModifiersEx != modifEx) {
     196            previousModifiersEx = modifEx;
     197            for (ModifierExListener m: modifierExListeners) {
     198                m.modifiersExChanged(modifEx);
     199            }
     200        }
     201
    164202        processKeyEvent(ke);
    165203    }
  • trunk/src/org/openstreetmap/josm/gui/util/ModifierListener.java

    r12304 r12517  
    66 * @since 7217
    77 * @since 10600 (functional interface)
     8 * @deprecated use ModifierExListener instead
    89 */
     10@Deprecated
    911@FunctionalInterface
    1012public interface ModifierListener {
Note: See TracChangeset for help on using the changeset viewer.