How to turn off translation of VK_CONTEXT_MENU key event into virtual mouse event?

Answered

I have some document editor where I catch and process key event VK_CONTEXT_MENU, as pure Java application it works well but as IntellijIDEA plugin it gets a mouse key press event to show PopUp context menu instead of original key event. Looks like that Intellij platform converts such key event into specific virtual mouse event. Is it possible to turn off such conversion for editor through IntellijIDEA plugin API and get just regular key event?

4 comments
Avatar
Vassiliy Kudryashov
Comment actions Permalink
Official comment

By default 'Context Menu' key is assigned to "Show Context Menu" actions in Preferences | Keymap. In different standard keymaps this action also has shortcuts Alt+F2, Shift+F10 or Control+F10.

Comment actions Permalink

I still have not found how to disable the event translation but found how to provide correct point for context menu

@Override
public Object getData(@String s) {
if (PlatformDataKeys.CONTEXT_MENU_POINT.is(s)) {
return this.document.findCorrectPoint();
}
return null;
}

but it looks like that the method (getData(CONTEXT_MENU_POINT)) is called often by platform (may be for mouse move)

0
Comment actions Permalink

Could you please clarify what "some document editor" is in terms of code? A custom Swing  UI component being re-used in the IDE? A custom com.intellij.openapi.editor.Editor implementation? What is your popup, a regular ActionGroup or some custom popup? In what class is your method getData() located in?

0
Comment actions Permalink

I use DocumentEditor which returns JBPanel which contains JScrollPane with my SWING based component. The problem is that for VK_CONTEXT_MENU press I get formed mouse event with popup trigger flag instead of key event and question is it possible or not to disable the mechanism. As I understand IDEA platform translating it somewhere in its deeps, because just pure Swing doesn't show such behaviour.

0

Please sign in to leave a comment.