Hi, I have the problem that I can't scroll with the mouse wheen in a ScrollPane, when the mouse is over an integrated WebView. Here is a small example:
public class WebViewInsideAScrollPane extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(final Stage stage) throws Exception {
final Scene scene = new Scene(getContent(), 500, 500);
stage.setScene(scene);
stage.show();
}
protected Parent getContent() {
final WebView webView = new WebView();
webView.getEngine().load("about:blank");
webView.setPrefSize(1000, 1000);
final Label label = new Label("TEXT");
label.setPrefSize(1000, 1000);
final Button button = new Button("press me");
final VBox vBox = new VBox();
vBox.getChildren().addAll(webView, label, button);
final ScrollPane scrollPane = new ScrollPane();
scrollPane.setContent(vBox);
final StackPane stackPane = new StackPane();
stackPane.getChildren().add(scrollPane);
return stackPane;
}
}
When the mouse is over the label, the scroll pane works fine with the mouse wheel but not over the WebView.
I have seen that in the WebView class a Scroll Event Handler is registrated, but it seems that it only delegates the scroll event to the containing page. Is there a way to disable it or to send it to the ScrollPane? I also see that this bug is in a Accordion with TitledPanes, where the content node are WebViews. I found a small workaround, but it would be better to have the option in the WebView:
webView.setOnScroll((EventHandler<ScrollEvent>) new EventHandler<ScrollEvent>() {
@Override
public void handle(ScrollEvent scrollEvent) {
final double percent = scrollEvent.getDeltaY() / scrollPane.getHeight();
scrollPane.setVvalue(scrollPane.getVvalue() + -percent);
}
});
public class WebViewInsideAScrollPane extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(final Stage stage) throws Exception {
final Scene scene = new Scene(getContent(), 500, 500);
stage.setScene(scene);
stage.show();
}
protected Parent getContent() {
final WebView webView = new WebView();
webView.getEngine().load("about:blank");
webView.setPrefSize(1000, 1000);
final Label label = new Label("TEXT");
label.setPrefSize(1000, 1000);
final Button button = new Button("press me");
final VBox vBox = new VBox();
vBox.getChildren().addAll(webView, label, button);
final ScrollPane scrollPane = new ScrollPane();
scrollPane.setContent(vBox);
final StackPane stackPane = new StackPane();
stackPane.getChildren().add(scrollPane);
return stackPane;
}
}
When the mouse is over the label, the scroll pane works fine with the mouse wheel but not over the WebView.
I have seen that in the WebView class a Scroll Event Handler is registrated, but it seems that it only delegates the scroll event to the containing page. Is there a way to disable it or to send it to the ScrollPane? I also see that this bug is in a Accordion with TitledPanes, where the content node are WebViews. I found a small workaround, but it would be better to have the option in the WebView:
webView.setOnScroll((EventHandler<ScrollEvent>) new EventHandler<ScrollEvent>() {
@Override
public void handle(ScrollEvent scrollEvent) {
final double percent = scrollEvent.getDeltaY() / scrollPane.getHeight();
scrollPane.setVvalue(scrollPane.getVvalue() + -percent);
}
});