You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2020/06/10 07:58:54 UTC

[royale-asjs] 02/03: Constrain ToolTip display to the visible area in MXRoyale. This prevents ToolTips being clipped when near edges (but placement could still be improved)

This is an automated email from the ASF dual-hosted git repository.

gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit 2fdc1370d0936033436e7cf38aeee41f227166ad
Author: greg-dove <gr...@gmail.com>
AuthorDate: Wed Jun 10 19:04:53 2020 +1200

    Constrain ToolTip display to the visible area in MXRoyale. This prevents ToolTips being clipped when near edges (but placement could still be improved)
---
 .../main/royale/mx/controls/beads/ToolTipBead.as   | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/ToolTipBead.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/ToolTipBead.as
index 6bae801..ab3f4fa 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/ToolTipBead.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/ToolTipBead.as
@@ -18,11 +18,15 @@
 ////////////////////////////////////////////////////////////////////////////////
 package mx.controls.beads
 {
+	import mx.core.FlexGlobals;
+	import mx.managers.SystemManager;
+
 	import org.apache.royale.core.IStrand;
 	import org.apache.royale.core.IUIBase;
 	import org.apache.royale.events.IEventDispatcher;
 	import org.apache.royale.events.MouseEvent;
 	import org.apache.royale.html.accessories.ToolTipBead;
+	import org.apache.royale.geom.Rectangle;
     
     import mx.core.UIComponent;
 	
@@ -73,8 +77,32 @@ package mx.controls.beads
                 if (tt)
                 {
                     tt.element.style.color = isError ? "#ff0000" : "#000";
+					adjustInsideBoundsIfNecessary();
                 }
             }
         }
+
+		COMPILE::JS
+		private function adjustInsideBoundsIfNecessary():void{ //could override determinePosition instead
+			var screen:Rectangle = ((FlexGlobals.topLevelApplication as UIComponent).systemManager as SystemManager).screen;
+			var deltaX:int = 0;
+			var deltaY:int = 0;
+			if (tt.x + tt.width > screen.width) {
+				deltaX -= (tt.x + tt.width - screen.width)
+			} else if (tt.x < 0) {
+				deltaX = tt.x;
+			}
+			if (tt.y + tt.height > screen.height) {
+				deltaY -= (tt.y + tt.height - screen.height)
+			} else if (tt.y < 0) {
+				deltaY = tt.y;
+			}
+
+			if (deltaX || deltaY) {
+				tt.x += deltaX;
+				tt.y += deltaY;
+			}
+		}
+
 	}
 }
\ No newline at end of file