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

Tooltip positioning "steals" hover causing tool-tip to incorrectly hide

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • jfx11, jfx20, 8, jfx17, jfx21
    • javafx
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Linux, Windows, Java 8u20+

      A DESCRIPTION OF THE PROBLEM :
      See this issue for reference:
      https://bugs.openjdk.org/browse/JDK-8094371

      The bug above was fixed in 8u20, but only for the default anchor location of WINDOW_TOP_LEFT (or other *TOP* anchor locations).

      The bug above still exists, with no known workaround, for the anchor location of WINDOW_BOTTOM_LEFT or any *BOTTOM* location.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Here is a minimal reproducible example, copied from closed bug JDK-8094371, but setting the anchor location to WINDOW_BOTTOM_LEFT.

      Drag the window to the right side of your screen, such that the tool-tip auto-fix behavior is used to adjust the position. Then notice that the tool-tip quickly hides after showing itself, and cycles hiding and showing (on Windows), or remains hidden (in my Linux environment).

      Alternatively, set the anchor location to WINDOW_BOTTOM_RIGHT and note that the bad behavior exists regardless of whether you're near the edge of the screen! The tool-tip will show/hide/show/hide in a loop regardless of owner location.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The tool-tip should remain showing for the configured visible duration, instead of hiding immediately.
      To accomplish this, the tool-tip must not steel focus from its owner, simply because of the configured anchor location and/or auto-fix setting.
      ACTUAL -
      The tool-tip steels the hover event from the owner node, causing it to hide itself.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.beans.binding.Bindings;
      import javafx.geometry.Pos;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Tooltip;
      import javafx.scene.layout.BorderPane;
      import javafx.stage.PopupWindow.AnchorLocation;
      import javafx.stage.Stage;

      public class ToolTipIssue extends Application {

         // boilerplate to build a button, add it to a stage, and show stage
         public static void main(String[] args) {
            launch(args);
         }

         @Override
         public void start(Stage primaryStage) {
            BorderPane root = new BorderPane();
            Button button = new Button();
            BorderPane.setAlignment(button, Pos.CENTER_RIGHT);
            button.textProperty().bind(Bindings.when(button.hoverProperty()).then("HOVERED Button")
                  .otherwise("Regular Button"));
            Tooltip tip = new Tooltip("I am a button's tooltip.");
            tip.setAnchorLocation(AnchorLocation.WINDOW_BOTTOM_LEFT);
            button.setTooltip(tip);
            root.setRight(button);
            primaryStage.setScene(new Scene(root, 450, 150));
            primaryStage.show();
         }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No known workaround if the user desires a tool-tip anchor location of WINDOW_BOTTOM_LEFT or WINDOW_BOTTOM_RIGHT. The only workaround is to use the default anchor location of WINDOW_TOP_LEFT or WINDOW_TOP_RIGHT, neither of which may be desirable depending on client needs.

      FREQUENCY : always

      edit 2023/09/05: on Mac, the tooltip shows and hides itself, then remains hidden.

        1. ToolTipIssue.java
          1 kB
          Praveen Narayanaswamy

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: