You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by al...@apache.org on 2021/08/26 12:15:14 UTC

[royale-asjs] branch develop updated: Splitter in MX HDividedBox added

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

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


The following commit(s) were added to refs/heads/develop by this push:
     new 7573967  Splitter in MX HDividedBox added
7573967 is described below

commit 7573967e20123068636242f1e667b37fca34a7e8
Author: alinakazi <al...@gmail.com>
AuthorDate: Thu Aug 26 17:15:04 2021 +0500

    Splitter in MX HDividedBox added
---
 .../src/main/royale/mx/containers/HDividedBox.as   | 28 +++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/containers/HDividedBox.as b/frameworks/projects/MXRoyale/src/main/royale/mx/containers/HDividedBox.as
index 42279ef..7730348 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/containers/HDividedBox.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/containers/HDividedBox.as
@@ -78,6 +78,7 @@ public class HDividedBox extends DividedBox
 	//  Constructor
 	//
 	//--------------------------------------------------------------------------
+	import org.apache.royale.events.MouseEvent;
 
 	/**
 	 *  Constructor.
@@ -92,9 +93,34 @@ public class HDividedBox extends DividedBox
 		super();
 		typeNames = "HDividedBox";
 		
-		super.direction = BoxDirection.HORIZONTAL;				
+		super.direction = BoxDirection.HORIZONTAL;	
+		addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
+		
+	}
+	protected function mouseDownHandler(event:MouseEvent):void
+	{
+		if (event.target != this)
+		{
+			return;
+		}
+		addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
+		topMostEventDispatcher.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
+	}
+	protected function mouseUpHandler(event:MouseEvent):void
+	{
+		removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
+		topMostEventDispatcher.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
 	}
 
+	protected function mouseMoveHandler(event:MouseEvent):void
+	{
+		var w1:int = Math.floor(100 * event.localX / width);
+		w1 = Math.min(w1, 95);
+		w1 = Math.max(w1, 5);
+		getChildAt(0).percentWidth = w1;
+		getChildAt(1).percentWidth = 100 - w1;
+		_layout.layout();
+	}
 	//--------------------------------------------------------------------------
 	//
 	//  Overridden properties