Detect mouse hovering over a Tooltip

552 views Asked by At

In relation to this question I would like to know if it is possible to trigger an event if the mouse is hovering over a Tooltip. I know this method node.setOnMouseEntered() but this applies only to instances of Node (Tooltip does not extend Node).

2

There are 2 answers

0
fabian On BEST ANSWER

Get the scene from the Tooltip and register the event handlers there:

Tooltip tooltip = new Tooltip("Something");
Scene tooltipScene = tooltip.getScene();

tooltipScene.setOnMouseEntered(evt -> {
    System.out.println("enter");
});
tooltipScene.setOnMouseExited(evt -> {
    System.out.println("exit");
});
2
Politic Revolutionnaire On

tooltip.getGraphic() will allow you to get a tooltip as a node.