mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-73775 Close content shortcut closes dialogs.
This commit is contained in:
@@ -105,4 +105,10 @@ public class CommonShortcuts {
|
||||
public static ShortcutSet getContextHelp() {
|
||||
return new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_CONTEXT_HELP));
|
||||
}
|
||||
|
||||
public static ShortcutSet getCloseActiveWindow() {
|
||||
return new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_CLOSE));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1400,7 +1400,7 @@ public abstract class DialogWrapper {
|
||||
}
|
||||
|
||||
private void registerKeyboardShortcuts() {
|
||||
getRootPane().registerKeyboardAction(new ActionListener() {
|
||||
ActionListener cancelKeyboardAction = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
MenuSelectionManager menuSelectionManager = MenuSelectionManager.defaultManager();
|
||||
MenuElement[] selectedPath = menuSelectionManager.getSelectedPath();
|
||||
@@ -1411,30 +1411,19 @@ public abstract class DialogWrapper {
|
||||
doCancelAction(e);
|
||||
}
|
||||
}
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
};
|
||||
getRootPane().registerKeyboardAction(cancelKeyboardAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
registerForEveryKeyboardShortcut(cancelKeyboardAction, CommonShortcuts.getCloseActiveWindow());
|
||||
|
||||
if (ApplicationInfo.contextHelpAvailable()) {
|
||||
ShortcutSet help = CommonShortcuts.getContextHelp();
|
||||
for (Shortcut shortcut : help.getShortcuts()) {
|
||||
if (shortcut instanceof KeyboardShortcut) {
|
||||
KeyboardShortcut ks = (KeyboardShortcut)shortcut;
|
||||
KeyStroke first = ks.getFirstKeyStroke();
|
||||
KeyStroke second = ks.getSecondKeyStroke();
|
||||
if (second == null) {
|
||||
getRootPane().registerKeyboardAction(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
doHelpAction();
|
||||
}
|
||||
}, first, JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getRootPane().registerKeyboardAction(new ActionListener() {
|
||||
ActionListener helpAction = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
doHelpAction();
|
||||
}
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_HELP, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
};
|
||||
|
||||
registerForEveryKeyboardShortcut(helpAction, CommonShortcuts.getContextHelp());
|
||||
getRootPane().registerKeyboardAction(helpAction, KeyStroke.getKeyStroke(KeyEvent.VK_HELP, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
}
|
||||
|
||||
if (myButtons != null) {
|
||||
@@ -1459,6 +1448,19 @@ public abstract class DialogWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private void registerForEveryKeyboardShortcut(ActionListener action, ShortcutSet shortcuts) {
|
||||
for (Shortcut shortcut : shortcuts.getShortcuts()){
|
||||
if (shortcut instanceof KeyboardShortcut) {
|
||||
KeyboardShortcut ks = (KeyboardShortcut)shortcut;
|
||||
KeyStroke first = ks.getFirstKeyStroke();
|
||||
KeyStroke second = ks.getSecondKeyStroke();
|
||||
if (second == null) {
|
||||
getRootPane().registerKeyboardAction(action, first, JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void focusPreviousButton() {
|
||||
for (int i = 0; i < myButtons.length; i++) {
|
||||
if (myButtons[i].hasFocus()) {
|
||||
|
||||
Reference in New Issue
Block a user