void (@NotNull AnActionEvent e) { RelativePoint relPoint = JBPopupFactory.getInstance().guessBestPopupLocation(e.getDataContext()); KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); Component focusOwner = focusManager.getFocusOwner(); Point point1 = relPoint.getPoint(focusOwner); Component deepest = ObjectUtils.notNull(UIUtil.getDeepestComponentAt(focusOwner, point1.x, point1.y / 2), focusOwner); Point point2 = relPoint.getPoint(deepest); Editor editor = e.getData(CommonDataKeys.EDITOR); int coord = editor != null ? Math.max(0, point2.y - 1) //To avoid cursor jump to the line below. http://www.jetbrains.net/jira/browse/IDEADEV-10644 : point2.y; MouseEvent event = new MouseEvent( focusOwner, MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), 0, point2.x, coord, 1, true, MouseEvent.BUTTON3); for (Component cur = deepest; cur != null; cur = cur.getParent()) { cur.dispatchEvent(event); if (event.isConsumed()) break; } }