IDEA-68100 Escape does not close the incremental search when using emacs keymaps

This commit is contained in:
andrey zaytsev
2011-04-25 15:07:39 +04:00
parent 58054a8127
commit 42f53ca4c4
@@ -8,6 +8,8 @@ import com.intellij.openapi.actionSystem.Shortcut;
import com.intellij.openapi.keymap.KeymapUtil;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
@@ -17,9 +19,15 @@ public class CloseOnESCAction extends EditorHeaderAction {
super(editorSearchComponent);
ArrayList<Shortcut> shortcuts = new ArrayList<Shortcut>();
shortcuts.add(new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), null));
if (KeymapUtil.isEmacsKeymap()) {
shortcuts.add(new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_MASK), null));
textField.registerKeyboardAction(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
CloseOnESCAction.this.actionPerformed(null);
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_FOCUSED);
} else {
shortcuts.add(new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), null));
}
registerCustomShortcutSet(new CustomShortcutSet(shortcuts.toArray(new Shortcut[shortcuts.size()])), textField);