From c884c18f33ae2a2779fd91a3eba75c3d435d7928 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Risto=20Yrj=C3=A4n=C3=A4?= Date: Wed, 12 Nov 2008 12:30:56 +0000 Subject: [PATCH] Added a switch for hiding the popup on mouse out svn changeset:5878/svn branch:trunk --- .../terminal/gwt/client/ui/IPopupView.java | 43 ++++++++----------- src/com/itmill/toolkit/ui/PopupView.java | 25 +++++++++++ 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java index 633dc82a81..640d4dafc6 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java @@ -103,6 +103,10 @@ public class IPopupView extends HTML implements Paintable { setTitle(uidl.getStringAttribute("description")); } + if (uidl.hasAttribute("hideOnMouseOut")) { + popup.setHideOnMouseOut(uidl.getBooleanAttribute("hideOnMouseOut")); + } + // Render the popup if visible and show it. if (hostPopupVisible) { UIDL popupUIDL = uidl.getChildUIDL(0); @@ -171,30 +175,7 @@ public class IPopupView extends HTML implements Paintable { * @param host * the widget to draw the popup on */ - // private void showPopupOnTop(final CustomPopup popup, final Widget host) { - // popup.setPopupPositionAndShow(new PopupPanel.PositionCallback() { - // public void setPosition(int offsetWidth, int offsetHeight) { - // int hostHorizontalCenter = host.getAbsoluteLeft() - // + host.getOffsetWidth() / 2; - // int hostVerticalCenter = host.getAbsoluteTop() - // + host.getOffsetHeight() / 2; - // - // int left = hostHorizontalCenter - offsetWidth / 2; - // int top = hostVerticalCenter - offsetHeight / 2; - // - // // Superclass takes care of top and left - // if ((left + offsetWidth) > windowRight) { - // left -= (left + offsetWidth) - windowRight; - // } - // - // if ((top + offsetHeight) > windowBottom) { - // top -= (top + offsetHeight) - windowBottom; - // } - // - // popup.setPopupPosition(left, top); - // } - // }); - // } + public void updateWindowSize() { windowTop = RootPanel.get().getAbsoluteTop(); windowLeft = RootPanel.get().getAbsoluteLeft(); @@ -216,6 +197,7 @@ public class IPopupView extends HTML implements Paintable { private ICaptionWrapper captionWrapper = null; private boolean hasHadMouseOver = false; + private boolean hideOnMouseOut = true; private final Set activeChildren; public CustomPopup() { @@ -242,9 +224,9 @@ public class IPopupView extends HTML implements Paintable { } if (!eventTargetsPopup & type == Event.ONMOUSEMOVE) { - if (hasHadMouseOver) { + + if (hasHadMouseOver && hideOnMouseOut) { hide(); - hasHadMouseOver = false; return true; } } @@ -265,6 +247,7 @@ public class IPopupView extends HTML implements Paintable { } activeChildren.clear(); remove(popupComponentWidget); + hasHadMouseOver = false; super.hide(); } @@ -353,6 +336,14 @@ public class IPopupView extends HTML implements Paintable { return new RenderSpace(windowRight, windowBottom); } + public boolean isHideOnMouseOut() { + return hideOnMouseOut; + } + + public void setHideOnMouseOut(boolean hideOnMouseOut) { + this.hideOnMouseOut = hideOnMouseOut; + } + }// class CustomPopup }// class IPopupView diff --git a/src/com/itmill/toolkit/ui/PopupView.java b/src/com/itmill/toolkit/ui/PopupView.java index 0eb4049c86..99c29902d4 100644 --- a/src/com/itmill/toolkit/ui/PopupView.java +++ b/src/com/itmill/toolkit/ui/PopupView.java @@ -20,6 +20,7 @@ public class PopupView extends AbstractComponentContainer { private Content content; private boolean popupVisible; + private boolean hideOnMouseOut; private final ArrayList componentList; /* Constructors */ @@ -57,6 +58,7 @@ public class PopupView extends AbstractComponentContainer { public PopupView(PopupView.Content content) { super(); popupVisible = false; + hideOnMouseOut = true; componentList = new ArrayList(1); setContent(content); } @@ -101,6 +103,28 @@ public class PopupView extends AbstractComponentContainer { return popupVisible; } + /** + * Check if this popup will be hidden when the user takes the mouse cursor + * out of the popup area. + * + * @return true if the popup is hidden on mouse out, false otherwise + */ + public boolean isHideOnMouseOut() { + return hideOnMouseOut; + } + + /** + * Should the popup automaticly hide when the user takes the mouse cursor + * out of the popup area? If this is false, the user must click outside the + * popup to close it. The default is true. + * + * @param hideOnMouseOut + * + */ + public void setHideOnMouseOut(boolean hideOnMouseOut) { + this.hideOnMouseOut = hideOnMouseOut; + } + /* * Methods inherited from AbstractComponentContainer. These are unnecessary * (but mandatory). Most of them are not supported in this implementation. @@ -199,6 +223,7 @@ public class PopupView extends AbstractComponentContainer { "Recieved null when trying to paint minimized value."); } target.addAttribute("html", content.getMinimizedValueAsHTML()); + target.addAttribute("hideOnMouseOut", hideOnMouseOut); // Only paint component to client if we know that the popup is showing if (popupVisible) { -- 2.39.5