JBCefClient (@NotNull CefContextMenuHandler handler, @NotNull CefBrowser browser) { return myContextMenuHandler.add(handler, browser, () -> { myCefClient.addContextMenuHandler(new CefContextMenuHandler() { @Override public void onBeforeContextMenu(CefBrowser browser, CefFrame frame, CefContextMenuParams params, CefMenuModel model) { myContextMenuHandler.handle(browser, handler -> { handler.onBeforeContextMenu(browser, frame, params, model); }); } @Override public boolean onContextMenuCommand(CefBrowser browser, CefFrame frame, CefContextMenuParams params, int commandId, int eventFlags) { return myContextMenuHandler.handleBoolean(browser, handler -> { return handler.onContextMenuCommand(browser, frame, params, commandId, eventFlags); }); } @Override public void onContextMenuDismissed(CefBrowser browser, CefFrame frame) { myContextMenuHandler.handle(browser, handler -> { handler.onContextMenuDismissed(browser, frame); }); } }); }); }