diff options
author | Anna Miroshnik <anna.miroshnik@arcadia.spb.ru> | 2014-11-25 12:19:05 +0300 |
---|---|---|
committer | Sauli Tähkäpää <sauli@vaadin.com> | 2014-11-28 12:30:26 +0200 |
commit | 1221f7a3acdcae84467e5ad42e7b2bd30e442f37 (patch) | |
tree | 49878359de3d3d76e66673edfc192ecc4a9f4eb0 /client/src | |
parent | ca05ce1963486a2e54600d36483e5155ef2ccfe4 (diff) | |
download | vaadin-framework-1221f7a3acdcae84467e5ad42e7b2bd30e442f37.tar.gz vaadin-framework-1221f7a3acdcae84467e5ad42e7b2bd30e442f37.zip |
Position tooltips in the visible area (#15129).
Based on Mika's reverted patch, with additional fix and test for
regression "an empty tooltip appears while the application is
initializing".
Change-Id: I8237fc9340265708a05a7576a5d9e8e374dc1fea
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/com/vaadin/client/VTooltip.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/client/src/com/vaadin/client/VTooltip.java b/client/src/com/vaadin/client/VTooltip.java index edd1273bf5..47a1b71228 100644 --- a/client/src/com/vaadin/client/VTooltip.java +++ b/client/src/com/vaadin/client/VTooltip.java @@ -210,6 +210,14 @@ public class VTooltip extends VOverlay { x = Window.getClientWidth() - offsetWidth - MARGIN + Window.getScrollLeft(); } + + if (tooltipEventMouseX != EVENT_XY_POSITION_OUTSIDE) { + // Do not allow x to be zero, for otherwise the tooltip + // does not close when the mouse is moved (see + // isTooltipOpen()). #15129 + int minX = Window.getScrollLeft() + MARGIN; + x = Math.max(x, minX); + } return x; } @@ -245,6 +253,14 @@ public class VTooltip extends VOverlay { y = Window.getScrollTop(); } } + + if (tooltipEventMouseY != EVENT_XY_POSITION_OUTSIDE) { + // Do not allow y to be zero, for otherwise the tooltip + // does not close when the mouse is moved (see + // isTooltipOpen()). #15129 + int minY = Window.getScrollTop() + MARGIN; + y = Math.max(y, minY); + } return y; } }); @@ -323,6 +339,7 @@ public class VTooltip extends VOverlay { setPopupPosition(tooltipEventMouseX, tooltipEventMouseY); } + private int EVENT_XY_POSITION_OUTSIDE = -5000; private int tooltipEventMouseX; private int tooltipEventMouseY; @@ -332,11 +349,13 @@ public class VTooltip extends VOverlay { } private int getEventX(Event event, boolean isFocused) { - return isFocused ? -5000 : DOM.eventGetClientX(event); + return isFocused ? EVENT_XY_POSITION_OUTSIDE : DOM + .eventGetClientX(event); } private int getEventY(Event event, boolean isFocused) { - return isFocused ? -5000 : DOM.eventGetClientY(event); + return isFocused ? EVENT_XY_POSITION_OUTSIDE : DOM + .eventGetClientY(event); } @Override |