I have a JavaFx Custom Bar Chart with label displayed on FXCanvas for SWT RCP application. Thanks to answers posted for How to clear text added in a javafx barchart?
However, when I add Mouse event listener to Nodes of the Bar Chart, Mouse event is not getting detected
private void addMouseListener(XYChart.Series<String, Number> series) {
for (XYChart.Data<String, Number> xyData : series.getData()) {
if (xyData != null && xyData.getNode() != null) {
final Node node = xyData.getNode();
node.setOnMousePressed((MouseEvent event) -> {
System.out.println("you clicked " + xyData.toString());
}
}
}
Invoking addMouseListener inside createBarChart with below lines of code
BarChartExt barChart = new BarChartExt<String, Number>(xAxis, yAxis);
barChart.setTitle("Summary");
Scene scene = new Scene(barChart, 300, 300);
barChart.getData().add(series);
addMouseListener(series)
scene.getStylesheets().add("css/barchart.css");
canvas.setScene(scene);
If I change the Custom BarChart to javafx.chart.BarChart class, events are recognised. Only for Custom BarChart mouse events are not firing.
Appreciate if any one could help me with this usecase. TIA