I have a ListView and would like to disable the traversal with arrow keys so that only a MouseEvent
would change the selected item. I was going to use a TraversalEngine
, but it seems as though that is deprecated. What is the best way to prevent the traversal? I get that I can do ListView.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>)
, but I'm not sure how to prevent the traversal...
I think you can try this:
listView.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
event.consume();
}
});