JComponent (@NotNull Presentation presentation, @NotNull String place) { JComponent component = new ActionButtonWithText(this, presentation, place, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE); ComponentUtil.putClientProperty(component, MnemonicHelper.MNEMONIC_CHECKER, keyCode -> KeyEvent.getExtendedKeyCodeForChar(TOGGLE) == keyCode || KeyEvent.getExtendedKeyCodeForChar(CHOOSE) == keyCode); MnemonicHelper.registerMnemonicAction(component, CHOOSE); InputMap map = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); int mask = MnemonicHelper.getFocusAcceleratorKeyMask(); map.put(KeyStroke.getKeyStroke(TOGGLE, mask, false), TOGGLE_ACTION_NAME); component.getActionMap().put(TOGGLE_ACTION_NAME, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { // mimic AnAction event invocation to trigger myEverywhereAutoSet=false logic DataContext dataContext = DataManager.getInstance().getDataContext(component); KeyEvent inputEvent = new KeyEvent( component, KeyEvent.KEY_PRESSED, e.getWhen(), MnemonicHelper.getFocusAcceleratorKeyMask(), KeyEvent.getExtendedKeyCodeForChar(TOGGLE), TOGGLE); AnActionEvent event = AnActionEvent.createFromAnAction( ScopeChooserAction.this, inputEvent, ActionPlaces.TOOLBAR, dataContext); ActionUtil.performDumbAwareWithCallbacks(ScopeChooserAction.this, event, ScopeChooserAction.this::onProjectScopeToggled); } }); if (ExperimentalUI.isNewUI()) { component.setBorder(JBUI.Borders.emptyRight(8)); } return component; }