I couldn't really explain the question in the title.
What I want to do is that when a right mouse-press (not click!) is performed on a element a ContextMenu shows up (this part is easy). The problem is that when I (still holding the mouse button) move my cursor over the items they do not get highlighted and when I release the mouse button the MenuItem does not get selected. The ContextMenu does not seem to be aware of the cursor until I release the button from the press that opened it.
Basically a right mouse-press shows a ContextMenu and releasing the button over a MenuItem should select it. What I am talking about is available in basically every single program (browsers, IDEs, etc.).
var contextMenu = new ContextMenu();
var mi1 = new MenuItem("Item 1");
mi1.setOnAction(e -> System.out.println("Item 1"));
var mi2 = new MenuItem("Item 2");
mi2.setOnAction(e -> System.out.println("Item 2"));
contextMenu.getItems().addAll(mi1, mi2);
node.setOnMousePressed(e -> {
if (e.getButton() == MouseButton.SECONDARY)
contextMenu.show(node, e.getScreenX(), e.getScreenY());
});