mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
OC-3524 + get context help shortcut from current keymap
This commit is contained in:
@@ -101,4 +101,8 @@ public class CommonShortcuts {
|
||||
public static ShortcutSet getFind() {
|
||||
return new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_FIND));
|
||||
}
|
||||
|
||||
public static ShortcutSet getContextHelp() {
|
||||
return new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_CONTEXT_HELP));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,7 @@ import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.MnemonicHelper;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CustomShortcutSet;
|
||||
import com.intellij.openapi.actionSystem.MacOtherAction;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationInfo;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
@@ -1416,17 +1413,29 @@ public abstract class DialogWrapper {
|
||||
}
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
|
||||
getRootPane().registerKeyboardAction(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
doHelpAction();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
|
||||
getRootPane().registerKeyboardAction(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
doHelpAction();
|
||||
}
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_HELP, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
getRootPane().registerKeyboardAction(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
doHelpAction();
|
||||
}
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_HELP, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
}
|
||||
|
||||
if (myButtons != null) {
|
||||
getRootPane().registerKeyboardAction(new AbstractAction() {
|
||||
|
||||
Reference in New Issue
Block a user