Ticket #8652: ToggleDialog_TAB.patch

File ToggleDialog_TAB.patch, 5.7 KB (added by akks, 6 years ago)

the rest of the patch, contain Tab-related changes

  • src/org/openstreetmap/josm/actions/DialogsToggleAction.java

     
    2929                tr("Toggle dialogs panel"),
    3030                (Icon) null, /* no icon */
    3131                tr("Toggle dialogs panel, maximize mapview"),
    32                 Shortcut.registerShortcut("menu:view:dialogspanel", tr("Toggle dialogs panel"),KeyEvent.CHAR_UNDEFINED, Shortcut.NONE),
     32                Shortcut.registerShortcut("menu:view:dialogspanel", tr("Toggle dialogs panel"),KeyEvent.VK_TAB, Shortcut.DIRECT),
    3333                true, "dialogspanel", /* register in toolbar */
    3434                false
    3535        );
  • src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

     
    127127                mapFrame, ImageProvider.getCursor("crosshair", null));
    128128
    129129        snappingShortcut = Shortcut.registerShortcut("mapmode:drawanglesnapping",
    130                 tr("Mode: Draw Angle snapping"), KeyEvent.VK_TAB, Shortcut.DIRECT);
     130                tr("Mode: Draw Angle snapping"), KeyEvent.CHAR_UNDEFINED, Shortcut.NONE);
    131131        snapChangeAction = new SnapChangeAction();
    132132        snapCheckboxMenuItem = addMenuItem();
    133133        snapHelper.setMenuCheckBox(snapCheckboxMenuItem);
  • src/org/openstreetmap/josm/gui/ExtendedDialog.java

     
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui;
    33
     4import java.awt.AWTKeyStroke;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    56
    67import java.awt.Component;
     8import java.awt.DefaultKeyboardFocusManager;
    79import java.awt.Dimension;
    810import java.awt.GridBagConstraints;
    911import java.awt.GridBagLayout;
     
    1416import java.util.Arrays;
    1517import java.util.Collections;
    1618import java.util.List;
     19import java.util.Set;
    1720
    1821import javax.swing.AbstractAction;
    1922import javax.swing.Action;
     23import javax.swing.FocusManager;
    2024import javax.swing.Icon;
    2125import javax.swing.JButton;
    2226import javax.swing.JCheckBox;
     
    100104     */
    101105    private boolean placeContentInScrollPane;
    102106
     107    /**
     108    * TAB is de-registered as a defaultFocusTraversalKey and reused
     109    * in the main application to quickly toggle dialogs.  Within
     110    * ExtendedDialogs however, we'll want TAB to traverse focus.
     111    */
     112    private static Set<AWTKeyStroke> defaultFocusTraversalKeys = (new DefaultKeyboardFocusManager()).getDefaultFocusTraversalKeys(FocusManager.FORWARD_TRAVERSAL_KEYS);
     113         
    103114    // For easy access when inherited
    104115    protected Insets contentInsets = new Insets(10,5,0,5);
    105116    protected ArrayList<JButton> buttons = new ArrayList<JButton>();
     
    147158            setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    148159        }
    149160        this.disposeOnClose = disposeOnClose;
     161        setFocusTraversalKeys(FocusManager.FORWARD_TRAVERSAL_KEYS, defaultFocusTraversalKeys);
    150162    }
    151163
    152164    /**
  • src/org/openstreetmap/josm/gui/MapFrame.java

     
    7575import org.openstreetmap.josm.gui.layer.Layer;
    7676import org.openstreetmap.josm.tools.Destroyable;
    7777import org.openstreetmap.josm.tools.GBC;
     78import org.openstreetmap.josm.tools.Shortcut;
    7879
    79 
    8080/**
    8181 * One Map frame with one dataset behind. This is the container gui class whose
    8282 * display can be set to the different views.
     
    236236        // status line below the map
    237237        statusLine = new MapStatus(this);
    238238        MapView.addLayerChangeListener(this);
     239       
     240         // unregister TAB key if needed
     241        if (Shortcut.findShortcut(KeyEvent.VK_TAB, 0) != null) {
     242            unregisterTabKey();
     243        }
    239244    }
    240245
     246    /**
     247    * Free tabulator key (call if someone else needs it)
     248    */
     249    public final void unregisterTabKey() {
     250        System.out.println("Tab key unregistered");
     251        HashSet<KeyStroke> ks = new HashSet<KeyStroke>(1);
     252        ks.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.CTRL_DOWN_MASK));
     253        KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
     254        kfm.setDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, ks);
     255        splitPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, ks);
     256    }
     257       
     258       
    241259    public boolean selectSelectTool(boolean onlyIfModeless) {
    242260        if(onlyIfModeless && !Main.pref.getBoolean("modeless", false))
    243261            return false;
  • src/org/openstreetmap/josm/tools/Shortcut.java

     
    245245    private static Map<Integer, Integer> groups= new HashMap<Integer, Integer>();
    246246
    247247    // check if something collides with an existing shortcut
    248     private static Shortcut findShortcut(int requestedKey, int modifier) {
     248    public static Shortcut findShortcut(int requestedKey, int modifier) {
    249249        if (modifier == getGroupModifier(NONE))
    250250            return null;
    251251        for (Shortcut sc : shortcuts.values()) {