Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Intellij IDEA how to show small dropdown-window next to carret?

I'm new to Intellij IDEA plugins and in java in general. I wrote my first plugin that checks carret pos and replaces px -> rem. That works fine, but i want to take it even further and make a new plugin for string manipulation that show's a small popup window show up, when shortcut is pressed and show options, where i can then use arrow keys & enter/space to select item.

Similar to this: enter image description here

But i can't seem to find any information for something like this in the Intellij plugin documentations..

Note that i don't want to add options to right click, instead, i want to trigger this small menu when plugin detects action using actionPerformed.

like image 686
PragmaticEd Avatar asked Nov 06 '22 22:11

PragmaticEd


1 Answers

You can do it using lookups:

LookupImpl lookup = (LookupImpl) LookupManager.getInstance(project).createLookup(editor, LookupElement.EMPTY_ARRAY, "", new LookupArranger.DefaultArranger());

lookup.addItem(LookupElementBuilder.create("Opt 1"), myPrefixMatcher);
lookup.addItem(LookupElementBuilder.create("Opt 2"), myPrefixMatcher);

lookup.showLookup();
like image 126
Feedforward Avatar answered Nov 14 '22 22:11

Feedforward