IDEA-141464 Debugger popup dissappears when trying to hover mouse on "+" dbe/142.2747
authorEgor.Ushakov <egor.ushakov@jetbrains.com>
Wed, 24 Jun 2015 18:02:02 +0000 (21:02 +0300)
committerEgor.Ushakov <egor.ushakov@jetbrains.com>
Wed, 24 Jun 2015 18:02:59 +0000 (21:02 +0300)
platform/platform-impl/src/com/intellij/ui/LightweightHint.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/common/AbstractValueHint.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/common/ValueLookupManager.java

index 8f4741f2b3c9202e56fe73eae2ae138adc61b364..eef552bf8fc0cdf7d95cc1a75555b4683e47b1fb 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -108,6 +108,10 @@ public class LightweightHint extends UserDataHolderBase implements Hint {
     myResizable = b;
   }
 
     myResizable = b;
   }
 
+  protected boolean canAutoHideOn(TooltipEvent event) {
+    return true;
+  }
+
   /**
    * Shows the hint in the layered pane. Coordinates <code>x</code> and <code>y</code>
    * are in <code>parentComponent</code> coordinate system. Note that the component
   /**
    * Shows the hint in the layered pane. Coordinates <code>x</code> and <code>y</code>
    * are in <code>parentComponent</code> coordinate system. Note that the component
@@ -144,7 +148,10 @@ public class LightweightHint extends UserDataHolderBase implements Hint {
           new IdeTooltip(hintHint.getOriginalComponent(), hintHint.getOriginalPoint(), myComponent, hintHint, myComponent) {
             @Override
             protected boolean canAutohideOn(TooltipEvent event) {
           new IdeTooltip(hintHint.getOriginalComponent(), hintHint.getOriginalPoint(), myComponent, hintHint, myComponent) {
             @Override
             protected boolean canAutohideOn(TooltipEvent event) {
-              if (event.getInputEvent() instanceof MouseEvent) {
+              if (!LightweightHint.this.canAutoHideOn(event)) {
+                return false;
+              }
+              else if (event.getInputEvent() instanceof MouseEvent) {
                 return !(hintHint.isContentActive() && event.isIsEventInsideBalloon());
               }
               else if (event.getAction() != null) {
                 return !(hintHint.isContentActive() && event.isIsEventInsideBalloon());
               }
               else if (event.getAction() != null) {
index d779a019cfa8a9e5b5719671068743058165587a..415e46cd2ccbd95d3f71b75119dd1f30c51e5881 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,12 +19,15 @@ import com.intellij.codeInsight.hint.HintManager;
 import com.intellij.codeInsight.hint.HintManagerImpl;
 import com.intellij.codeInsight.hint.HintUtil;
 import com.intellij.codeInsight.navigation.NavigationUtil;
 import com.intellij.codeInsight.hint.HintManagerImpl;
 import com.intellij.codeInsight.hint.HintUtil;
 import com.intellij.codeInsight.navigation.NavigationUtil;
+import com.intellij.ide.TooltipEvent;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.colors.EditorColors;
 import com.intellij.openapi.editor.colors.EditorColorsManager;
 import com.intellij.openapi.editor.colors.EditorColorsScheme;
 import com.intellij.openapi.editor.event.EditorMouseEvent;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.colors.EditorColors;
 import com.intellij.openapi.editor.colors.EditorColorsManager;
 import com.intellij.openapi.editor.colors.EditorColorsScheme;
 import com.intellij.openapi.editor.event.EditorMouseEvent;
+import com.intellij.openapi.editor.impl.EditorComponentImpl;
+import com.intellij.openapi.editor.impl.EditorImpl;
 import com.intellij.openapi.editor.markup.HighlighterLayer;
 import com.intellij.openapi.editor.markup.HighlighterTargetArea;
 import com.intellij.openapi.editor.markup.RangeHighlighter;
 import com.intellij.openapi.editor.markup.HighlighterLayer;
 import com.intellij.openapi.editor.markup.HighlighterTargetArea;
 import com.intellij.openapi.editor.markup.RangeHighlighter;
@@ -46,10 +49,7 @@ import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import java.awt.*;
 
 import javax.swing.*;
 import java.awt.*;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
+import java.awt.event.*;
 import java.util.EventObject;
 
 /**
 import java.util.EventObject;
 
 /**
@@ -105,14 +105,17 @@ public abstract class AbstractValueHint {
       }
     }
     else {
       }
     }
     else {
-      int offset = calculateOffset(editor, point);
-      if (myCurrentRange != null && myCurrentRange.getStartOffset() <= offset && offset <= myCurrentRange.getEndOffset()) {
+      if (isInsideCurrentRange(editor, point)) {
         return true;
       }
     }
     return false;
   }
 
         return true;
       }
     }
     return false;
   }
 
+  boolean isInsideCurrentRange(Editor editor, Point point) {
+    return myCurrentRange != null && myCurrentRange.contains(calculateOffset(editor, point));
+  }
+
   public static int calculateOffset(@NotNull Editor editor, @NotNull Point point) {
     return editor.logicalPositionToOffset(editor.xyToLogicalPosition(point));
   }
   public static int calculateOffset(@NotNull Editor editor, @NotNull Point point) {
     return editor.logicalPositionToOffset(editor.xyToLogicalPosition(point));
   }
@@ -193,7 +196,20 @@ public abstract class AbstractValueHint {
     if (myCurrentHint != null) {
       myCurrentHint.hide();
     }
     if (myCurrentHint != null) {
       myCurrentHint.hide();
     }
-    myCurrentHint = new LightweightHint(component);
+    myCurrentHint = new LightweightHint(component) {
+      @Override
+      protected boolean canAutoHideOn(TooltipEvent event) {
+        InputEvent inputEvent = event.getInputEvent();
+        if (inputEvent instanceof MouseEvent) {
+          Component comp = inputEvent.getComponent();
+          if (comp instanceof EditorComponentImpl) {
+            EditorImpl editor = ((EditorComponentImpl)comp).getEditor();
+            return !isInsideCurrentRange(editor, ((MouseEvent)inputEvent).getPoint());
+          }
+        }
+        return true;
+      }
+    };
     myCurrentHint.addHintListener(new HintListener() {
       @Override
       public void hintHidden(EventObject event) {
     myCurrentHint.addHintListener(new HintListener() {
       @Override
       public void hintHidden(EventObject event) {
index 9684b88e5efcb9b0cd9d40587480f97d42a69993..a3c591b667cf52513507ee5f92cbb4af836afdc6 100644 (file)
@@ -23,7 +23,10 @@ package com.intellij.xdebugger.impl.evaluate.quick.common;
 import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.EditorFactory;
 import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.EditorFactory;
-import com.intellij.openapi.editor.event.*;
+import com.intellij.openapi.editor.event.EditorMouseAdapter;
+import com.intellij.openapi.editor.event.EditorMouseEvent;
+import com.intellij.openapi.editor.event.EditorMouseEventArea;
+import com.intellij.openapi.editor.event.EditorMouseMotionListener;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.registry.Registry;
@@ -91,6 +94,9 @@ public class ValueLookupManager extends EditorMouseAdapter implements EditorMous
     if (myRequest != null && !myRequest.isKeepHint(editor, point)) {
       hideHint();
     }
     if (myRequest != null && !myRequest.isKeepHint(editor, point)) {
       hideHint();
     }
+    else if (type == ValueHintType.MOUSE_OVER_HINT && myRequest != null && !myRequest.isHintHidden() && myRequest.isInsideCurrentRange(editor, point)) {
+      return;
+    }
 
     for (DebuggerSupport support : mySupports) {
       QuickEvaluateHandler handler = support.getQuickEvaluateHandler();
 
     for (DebuggerSupport support : mySupports) {
       QuickEvaluateHandler handler = support.getQuickEvaluateHandler();