void () { myComponent.addComponentListener(new ComponentAdapter() { @Override public void componentHidden(ComponentEvent event) { manageSearchPopup(null); } @Override public void componentMoved(ComponentEvent event) { moveSearchPopup(); } @Override public void componentResized(ComponentEvent event) { moveSearchPopup(); } }); myComponent.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { if (!keepEvenWhenFocusLost()) { manageSearchPopup(null); } } @Override public void focusGained(FocusEvent e) { if (!isStickySearch()) return; String text = ClientProperty.get(myComponent, SEARCH_TEXT_KEY); if (Strings.isEmpty(text)) { return; } ApplicationManager.getApplication().invokeLater(() -> { if (myComponent.hasFocus()) { manageSearchPopup(createPopup(text)); // keep selection } }); } }); myComponent.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { processKeyEvent(e); } @Override public void keyPressed(KeyEvent e) { processKeyEvent(e); } }); new DumbAwareAction() { @Override public void actionPerformed(@NotNull AnActionEvent e) { String prefix = getEnteredPrefix(); String[] strings = NameUtilCore.splitNameIntoWords(prefix); if (strings.length == 0) return; // "__" has no words String last = strings[strings.length - 1]; int i = prefix.lastIndexOf(last); mySearchPopup.mySearchField.setText(prefix.substring(0, i).trim()); } @Override public void update(@NotNull AnActionEvent e) { e.getPresentation().setEnabled(isPopupActive() && Strings.isNotEmpty(getEnteredPrefix())); } @Override public @NotNull ActionUpdateThread getActionUpdateThread() { return ActionUpdateThread.EDT; } }.registerCustomShortcutSet(CustomShortcutSet.fromString(SystemInfo.isMac ? "meta BACK_SPACE" : "control BACK_SPACE"), myComponent); ActionManager.getInstance().getAction(SpeedSearchAction.ID).registerCustomShortcutSet(myComponent, null); installSupplyTo(myComponent); }