2

I'm on javafx-8 and java8, trying to make an interactive chart.

So far I've implemented all the mouse actions (highlight on mouse over, drag&drop to change values etc), but I'm not able to implement any keyboard interactions (basically changing its value with arrow keys) because the nodes (i.e. pic below) in a chart cannot gain focus.

enter image description here

When I try to set the focusTraversable property is fails with exception

java.lang.RuntimeException: StackPane.focusTraversable : A bound value cannot be set.

I have tried setting it on the chart but it doesn't get propagated to the data points (nodes). Can someone please point me the right way? thanks!

kleopatra
  • 51,061
  • 28
  • 99
  • 211
John
  • 660
  • 10
  • 26
  • The exception says you have already bound the focusTraversableProperty, and therefor you cannot set it manuall using .setFocusTraversable(true); anymore – Psychokiller1888 Dec 02 '15 at 07:00
  • thanks, I understand that it is bound but I cannot find the variable it is bound to. I tried setting focusTraversable on the chart the node belong to but that didn't help either. – John Dec 02 '15 at 09:48

1 Answers1

1

The binding of the symbol's focusTraversal is used in accessibility - the snippet from LineChart.createSymbol(..):

symbol.focusTraversableProperty().bind(Platform.accessibilityActiveProperty());

As long as you can live without following accessibility constraints, you might get away (untested for side-effects!) by simply unbinding before setting it to true, something like:

Node node = data.getNode();
node.focusTraversableProperty().unbind();
node.setFocusTraversable(true);
kleopatra
  • 51,061
  • 28
  • 99
  • 211