Few days ago I found problem with tooltip styling.
I wanted to show tooltip on demand (when TextField get focus) and I also wanted to style this tooltip using custom css like this:
I got result that when I hovered mouse on
TextField then my style was applied correctly but when I show tooltip on focus event using
tooltip.show(...) then tooltip didn’t get my style.
This is due to
getStyleableParent method of
Tooltip class with is responsible for style “propagation”. In
getStyleableParent looks like this:
BEHAVIOR is static class responsible for properly showing and hiding tooltip when mouse is over
hoveredNode property is set in mouse move event handler on the
node that have installed
tooltip supported by
BEHAVIOR class. Therefore, when you use
show method to manually show tooltip then
BEHAVIOR.hoveredNode property is not set and also you don’t have chance to change it, because
BEHAVIOR is private class.
I found solution by overriding
getStyleableParent and returning
ownerNode which is set when you show
tooltip using method of
Here is example application where you see how it works: