Modify context menu in JavaFX WebView

后端 未结 1 2015
旧时难觅i
旧时难觅i 2021-01-13 06:13

I\'m trying to add some options to the context menu in a JavaFX WebView when the user right clicks a link, however I can\'t figure out how to do it.

I found I could

相关标签:
1条回答
  • 2021-01-13 06:55

    Currently that's not possible. There is an open issue on JavaFX for that: https://javafx-jira.kenai.com/browse/RT-20306

    If you just want to add a different context menu, then you could do that

     webView.setOnMouseClicked(new EventHandler<MouseEvent>() {
    
                    @Override
                    public void handle(MouseEvent mouse) {
                        if (mouse.getButton() == MouseButton.SECONDARY) {
                            menu = new ContextMenu();
                           //add some menu items here
                           menu.show(this, mouse.getScreenX(), mouse.getScreenY());
                        } else {
                            if (menu != null) {
                                menu.hide();
                            }
                        }
                    }
                });
    
    0 讨论(0)
提交回复
热议问题