简体   繁体   中英

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: 在此输入图像描述

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 .

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM