Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8296387

[Tooltip, CSS] -fx-show-delay is only applied to the first tooltip that is shown before it is displayed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • jfx24
    • jfx11, 9
    • javafx
    • None
    • 9
    • b01

      For other nodes with tooltips, -fx-show-delay is not applied until their tooltips are displayed once, which happens using the default delay time of 1000 ms.

      The attached test case, with just this css style:

      .tooltip {
          -fx-show-delay: 10ms;
      }

       shows the issue, after doing the following steps:

      - Start application
      - Hover over button 1 repeatedly (without waiting 1 second), see the output:


      Tooltip 1 delay: 1000.0 ms
      Tooltip 1 shown
      Tooltip 1 shown
      Tooltip 1 delay: 10.0 ms
      Tooltip 1 shown
      Tooltip 1 delay: 10.0 ms
      Tooltip 1 shown
      Tooltip 1 delay: 10.0 ms
      Tooltip 1 shown
      ...

      every time the mouse is over the button 1, the tooltip 1 is displayed, and with the expected 10 ms delay.

      - Hover over button 2 repeatedly (without waiting 1 second), see the output:

      Tooltip 2 delay: 1000.0 ms
      Tooltip 2 delay: 1000.0 ms
      Tooltip 2 delay: 1000.0 ms
      Tooltip 2 delay: 1000.0 ms
      ...

      the tooltip 2 is never displayed, which is unexpected.

      - Hover over button 2 again, wait one second, and then enter/exit repeatedly (without waiting 1 second), see the output:

      Tooltip 2 delay: 1000.0 ms
      Tooltip 2 shown
      Tooltip 2 delay: 10.0 ms
      Tooltip 2 shown
      Tooltip 2 delay: 10.0 ms
      Tooltip 2 shown
      Tooltip 2 delay: 10.0 ms
      Tooltip 2 shown
       ...

      After waiting one second, the tooltip 2 is displayed, and then it will always take the expected 10 ms.

      There is a cssForced [1] flag that forces the CSS processing in TooltipBehavior, but that is only applied for the first tooltip that requires it, because TooltipBehavior is a static class shared by all nodes with tooltips.

      (this CSS processing explains why the first time the tooltip 1 from the above test is displayed it is shown twice)

      This issue can be reproduced with any JavaFX version since 9.

      [1] https://github.com/openjdk/jfx/blob/master/modules/javafx.controls/src/main/java/javafx/scene/control/Tooltip.java#L1001

            mhanl Marius Hanl
            jpereda Jose Pereda
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: