This discussion is archived
5 Replies Latest reply: Nov 27, 2012 8:57 AM by edward17 RSS

Tooltip Hell

edward17 Newbie
Currently Being Moderated
Ok, I am in the bowels of TooTip Hell.

Scenario One:
I have a large window. On top of that is another window, a smaller window. So the user is using the top window. They want it to be the top window. They are happy on top.

Mouse cursor slips over to bottom window. They slip it back and are happy because they are still on top.

The mouse cursor slips again. This time when the cursor moves over the bottom window, it happens on a field with a tooltip. Before they can move the cursor back, the tooltip pops up, brings the bottom window to the top with it, and pushes the smaller window to the bottom. The user is unhappy.

Scenario Two:
I have a large window. The user hovers over a save button. They click Save. A dialog pops up confirming their data is safe. parent.getScene().getRoot().setEffect(new BoxBlur()); ias executed to obscur the parent window isnce this dialog is MODAL. The user selects OK, the dialog closes, and the parent window is readable again.

Happy with their experience, the user does some more work, they drag the mouse cursor to the Save button again. However, they are tired, so they are moving slower, and happen to linger a little too long on another control along the way. They trigger a tooltip, but before it is rendered, they make it to the save button and click it. The dialog box confirming their save pops up, and the parent is blurred. Then the tooltip of the parent pops up, pushes the modal dialog to the back. Now the user has a tooltip on a blurred window on top, and a modal dialog they can't proceed without somewhere in their deep stack of many open windows. They curse my name and cease to buy my product, because it is so unprofessional.

Suggestions? Guess I am looking for a way to insure a tooltip doesn't chnage the top to bottom order of my windows under ANY circumstances.
  • 1. Re: Tooltip Hell
    jsmith Guru
    Currently Being Moderated
    One solution is to create your own tooltip skin (or node subclass) which does not use a popup window.

    Make the parent of the Pane having the tooltip overlaid a StackPane, place your main content on the bottom of the stack and the tooltip content (when needed) layering over the base content when you hover.

    Here is some sample code I used for something similar before (in this case it was a document modal dialog box for a web browser, but it should also work for a custom tooltip with some adjustment):
      /**
       * Overlay a dialog on top of the webview.
       * @param dialogNode the dialog to overlay on top of the view.
       */
      private void overlayView(Node dialogNode) {
        // if the view is already overlaid we will just ignore this overlay call silently . . . todo probably not the best thing to do, but ok for now.
        if (!(getView().getParent() instanceof BorderPane)) return;
    
        // record the view's parent.
        BorderPane viewParent = (BorderPane) getView().getParent();
    
        // create an overlayPane layering the popup on top of the webview
        StackPane overlayPane = new StackPane();
        overlayPane.getChildren().addAll(getView(), new Group(dialogNode));
        getView().setDisable(true);
    
        // overlay the popup on the webview.
        viewParent.setCenter(overlayPane);
      }
    ....
      private void removeViewOverlay() {
        BorderPane viewParent = (BorderPane) getView().getParent().getParent();
        viewParent.setCenter(getView());
      }
    There may be some other solution if you want to use the standard Tooltip class with it's popup window, but I don't know what that is.
  • 2. Re: Tooltip Hell
    973901 Newbie
    Currently Being Moderated
    I present to you a workaround worthy of our Neanderthal ancestors.
    final TextField field = new TextField();
    final Tooltip tip = new Tooltip("Bothersome tooltip");
    field.setOnMouseEntered(new EventHandler<MouseEvent>()
    {
         public void handle(MouseEvent evt)
         {
              if (stage.isFocused())
                   field.setTooltip(tip);
              else
                   field.setTooltip(null);
         }
    });
    Clunky as hell, but it works =P
  • 3. Re: Tooltip Hell
    Marcello Newbie
    Currently Being Moderated
    I also have had issues with tooltip, many months ago. Problems occured when you have multiple monitors and when you try to popup the toolitip manually..I do not know whether this issues have been fixed meanwhile, anyway I decided to create my own tooltip at that time and since then I never ever had problems again.
  • 4. Re: Tooltip Hell
    edward17 Newbie
    Currently Being Moderated
    I had a look at the ToolTop code on openjdkjfx

    Is there a way to determine if a window is on top? If so I could clone the existing code, make minor change, and all would be well.
  • 5. Re: Tooltip Hell
    edward17 Newbie
    Currently Being Moderated
    OK, wow, never expected this.

    I had NOT been assigning owner windows to my dialogs. Once I did my tooltip Hell evaporated in a puff of sulfurous smoke!!!!

    myStage.initOwner(<myMainWindow>);

    truly all the problems went away with this one change! Hurrah!!!

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points