You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by yi...@apache.org on 2019/12/19 07:13:10 UTC

[royale-asjs] branch adg_grouped updated (f5cfbf4 -> 4a95681)

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

yishayw pushed a change to branch adg_grouped
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git.


    from f5cfbf4  Try using AdvancedDataGridHeaderRenderer in AdvancedDataGrid
     new d21f060  Take care of case where you want to drop a dragged item outside app
     new 4a95681  This flag needs to be raised somewhere other than init

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../main/royale/org/apache/royale/css2/Cursors.as  |  17 +-
 .../DragDrop/src/main/resources/basic-manifest.xml |  14 +-
 .../html/beads/OutOfApplicationDropTargetBead.as   | 167 +++++++++++++++++++
 .../html/beads/SingleSelectionDragSourceBead.as    |   1 +
 .../OutOfApplicationDropMouseController.as         | 180 +++++++++++++++++++++
 5 files changed, 366 insertions(+), 13 deletions(-)
 create mode 100644 frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/OutOfApplicationDropTargetBead.as
 create mode 100644 frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/controllers/OutOfApplicationDropMouseController.as


[royale-asjs] 01/02: Take care of case where you want to drop a dragged item outside app

Posted by yi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d21f060a8462d5b22ba88c1d8ad0ede2ad91a6c7
Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
AuthorDate: Wed Dec 11 11:19:49 2019 +0200

    Take care of case where you want to drop a dragged item outside app
---
 .../main/royale/org/apache/royale/css2/Cursors.as  |  17 +-
 .../DragDrop/src/main/resources/basic-manifest.xml |  14 +-
 .../html/beads/OutOfApplicationDropTargetBead.as   | 167 +++++++++++++++++++
 .../OutOfApplicationDropMouseController.as         | 180 +++++++++++++++++++++
 4 files changed, 365 insertions(+), 13 deletions(-)

diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/css2/Cursors.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/css2/Cursors.as
index ca4a9c3..91de6da 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/css2/Cursors.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/css2/Cursors.as
@@ -18,6 +18,9 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.royale.css2
 {
+	import org.apache.royale.core.IStrand;
+	import org.apache.royale.events.IEventDispatcher;
+	import org.apache.royale.core.IRenderedObject;
     import org.apache.royale.core.IUIBase;
     import org.apache.royale.core.ValuesManager;
     import org.apache.royale.events.MouseEvent;
@@ -98,11 +101,11 @@ package org.apache.royale.css2
          *  @playerversion AIR 2.6
          *  @productversion Royale 0.0
          */
-		public static function getCursor(obj:IUIBase):String
+		public static function getCursor(obj:IRenderedObject):String
 		{
             COMPILE::SWF
             {
-                var cursorData:CursorData =  obj.getBeadByType(CursorData) as CursorData;
+                var cursorData:CursorData =  (obj as IStrand).getBeadByType(CursorData) as CursorData;
                 if (cursorData)
                     return cursorData.cursor;
                 return Mouse.cursor;
@@ -116,17 +119,17 @@ package org.apache.royale.css2
         /**
          *  @private
          */
-		public static function setCursor(obj:IUIBase, cursor:String):void
+		public static function setCursor(obj:IRenderedObject, cursor:String):void
 		{
             COMPILE::SWF
             {
-                var cursorData:CursorData =  obj.getBeadByType(CursorData) as CursorData;
+                var cursorData:CursorData =  (obj as IStrand).getBeadByType(CursorData) as CursorData;
                 if (!cursorData)
                 {
                     cursorData = new CursorData();
-                    obj.addBead(cursorData);
-                    obj.addEventListener(MouseEvent.MOUSE_OVER, overHandler);
-                    obj.addEventListener(MouseEvent.MOUSE_OUT, outHandler);
+                    (obj as IStrand).addBead(cursorData);
+                    (obj as IEventDispatcher).addEventListener(MouseEvent.MOUSE_OVER, overHandler);
+                    (obj as IEventDispatcher).addEventListener(MouseEvent.MOUSE_OUT, outHandler);
                 }
                 if (builtinCursors.indexOf(cursor) == -1)
                 {
diff --git a/frameworks/projects/DragDrop/src/main/resources/basic-manifest.xml b/frameworks/projects/DragDrop/src/main/resources/basic-manifest.xml
index c21964c..5547f7e 100644
--- a/frameworks/projects/DragDrop/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/DragDrop/src/main/resources/basic-manifest.xml
@@ -29,18 +29,20 @@
 	<component id="SingleSelectionDropTargetBead" class="org.apache.royale.html.beads.SingleSelectionDropTargetBead" />
 	<component id="SensitiveSingleSelectionDropTargetBead" class="org.apache.royale.html.beads.SensitiveSingleSelectionDropTargetBead" />
 	<component id="SensitiveMultiSelectionDropTargetBead" class="org.apache.royale.html.beads.SensitiveMultiSelectionDropTargetBead" />
-    <component id="DragMouseController" class="org.apache.royale.html.beads.controllers.DragMouseController" />
-    <component id="DropMouseController" class="org.apache.royale.html.beads.controllers.DropMouseController" />
-    	
+	<component id="OutOfApplicationDropTargetBead" class="org.apache.royale.html.beads.OutOfApplicationDropTargetBead" />
+	<component id="DragMouseController" class="org.apache.royale.html.beads.controllers.DragMouseController" />
+	<component id="DropMouseController" class="org.apache.royale.html.beads.controllers.DropMouseController" />
+	<component id="OutOfApplicationDropMouseController" class="org.apache.royale.html.beads.controllers.OutOfApplicationDropMouseController" />
+
 	<component id="DataGridDrawingLayerBead" class="org.apache.royale.html.beads.DataGridDrawingLayerBead" />
 	<component id="DataGridWithDrawingLayerLayout" class="org.apache.royale.html.beads.DataGridWithDrawingLayerLayout" />
 	<component id="DragDropListView" class="org.apache.royale.html.beads.DragDropListView" />
 	<component id="ListDrawingLayerBead" class="org.apache.royale.html.beads.ListDrawingLayerBead" />
-	
+
 	<component id="DataGridButtonBarViewForMovableColumns" class="org.apache.royale.html.beads.DataGridButtonBarViewForMovableColumns" />
 	<component id="DataGridColumnReorderView" class="org.apache.royale.html.beads.DataGridColumnReorderView" />
 	<component id="ButtonBarReorderBead" class="org.apache.royale.html.beads.ButtonBarReorderBead" />
-	
+
 	<component id="DataGridDragDropBead" class="org.apache.royale.html.beads.DataGridDragDropBead" />
-	
+
 </componentPackage>
diff --git a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/OutOfApplicationDropTargetBead.as b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/OutOfApplicationDropTargetBead.as
new file mode 100644
index 0000000..e30bfc4
--- /dev/null
+++ b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/OutOfApplicationDropTargetBead.as
@@ -0,0 +1,167 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package org.apache.royale.html.beads
+{
+	import org.apache.royale.collections.ArrayList;
+	import org.apache.royale.core.DropType;
+	import org.apache.royale.core.IBead;
+	import org.apache.royale.core.IStrand;
+	import org.apache.royale.core.IUIBase;
+	import org.apache.royale.core.UIBase;
+	import org.apache.royale.events.DragEvent;
+	import org.apache.royale.events.Event;
+	import org.apache.royale.events.EventDispatcher;
+	import org.apache.royale.events.IEventDispatcher;
+	import org.apache.royale.html.beads.controllers.OutOfApplicationDropMouseController;
+
+
+	/**
+	 * The enter event is dispatched when a DragEnter has been detected in the drop target
+	 * strand. This event can be used to determine if the strand can and will accept the data
+	 * being dragged onto it. If the data cannot be used by the drop target strand this event
+	 * should be cancelled.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.9.7
+	 */
+	[Event(name="enter", type="org.apache.royale.events.Event")]
+
+	/**
+	 * The exit event is sent when the drag goes outside of the drop target space.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.9.7
+	 */
+	[Event(name="exit", type="org.apache.royale.events.Event")]
+
+	/**
+	 * The complete event is dispatched when the drop operation has completed from the drop
+	 * target's perspective.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.9.7
+	 */
+
+	[Event(name="drop", type="org.apache.royale.events.Event")]
+	/**
+	 * The drop event is dispatched when the drop operation is about to be completed. DragEvent.dragSource is still available
+	 *  and default can still be prevented.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.9.7
+	 */
+
+	[Event(name="complete", type="org.apache.royale.events.Event")]
+	/**
+	 *  The OutOfApplicationDropTargetBead enables items to be dropped outside of the application
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.9.7
+	 */
+
+	public class OutOfApplicationDropTargetBead extends EventDispatcher implements IBead
+	{
+		/**
+		 * Constructor
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.7
+		 */
+		public function OutOfApplicationDropTargetBead()
+		{
+			super();
+		}
+
+		private var _dropController:OutOfApplicationDropMouseController;
+		private var _strand:IStrand;
+
+		/**
+		 * @private
+		 *  @royaleignorecoercion org.apache.royale.events.IEventDispatcher
+		 */
+		public function set strand(value:IStrand):void
+		{
+			_strand = value;
+
+			_dropController = new OutOfApplicationDropMouseController();
+			_strand.addBead(_dropController);
+
+			_dropController.addEventListener(DragEvent.DRAG_ENTER, handleDragEnter);
+			_dropController.addEventListener(DragEvent.DRAG_EXIT, handleDragExit);
+			_dropController.addEventListener(DragEvent.DRAG_DROP, handleDragDrop);
+		}
+
+		/**
+		 * @private
+		 */
+		private function handleDragEnter(event:DragEvent):void
+		{
+			var newEvent:Event = new Event("enter", false, true);
+			dispatchEvent(newEvent);
+			if (newEvent.defaultPrevented) return;
+
+			_dropController.acceptDragDrop(event.relatedObject as IUIBase, DropType.COPY);
+		}
+
+		/**
+		 * @private
+		 */
+		private function handleDragDrop(event:DragEvent):void
+		{
+			handleDragExit(event);
+
+			var newEvent:Event = new Event("drop", false, true);
+			dispatchEvent(newEvent);
+			if (newEvent.defaultPrevented) {
+				return;
+			}
+
+			// Let the dragInitiator know the drop has been completed.
+			if (DragEvent.dragInitiator) {
+				DragEvent.dragInitiator.acceptedDrop(_strand, "object");
+			}
+
+			// is this event necessary? isn't "complete" enough?
+			IEventDispatcher(_strand).dispatchEvent(new Event("dragDropAccepted"));
+
+			dispatchEvent(new Event("complete"));
+		}
+
+		/*
+		 * @private
+		 */
+		private function handleDragExit(event:DragEvent):void
+		{
+			dispatchEvent(new Event("exit", false, true));
+		}
+	}
+}
diff --git a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/controllers/OutOfApplicationDropMouseController.as b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/controllers/OutOfApplicationDropMouseController.as
new file mode 100644
index 0000000..e807350
--- /dev/null
+++ b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/controllers/OutOfApplicationDropMouseController.as
@@ -0,0 +1,180 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.html.beads.controllers
+{
+	import org.apache.royale.events.MouseEvent;
+	import org.apache.royale.core.IBead;
+	import org.apache.royale.core.IDragInitiator;
+	import org.apache.royale.core.IStrand;
+	import org.apache.royale.core.IUIBase;
+	import org.apache.royale.events.DragEvent;
+	import org.apache.royale.events.EventDispatcher;
+	import org.apache.royale.events.IEventDispatcher;
+	import org.apache.royale.css2.Cursors;
+	import org.apache.royale.core.IRenderedObject;
+
+	COMPILE::JS {
+		import org.apache.royale.events.BrowserEvent;
+	}
+
+    /**
+     *  Indicates that the mouse has gone outside the app during
+     *  a drag operation. Note that we are entering the drop target
+     *  when exiting the application, hence the event name.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.9.7
+     */
+    [Event(name="dragEnter", type="org.apache.royale.events.DragEvent")]
+
+    /**
+     *  Indicates that the mouse is moving out of a component during
+     *  a drag/drop operation.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.9.7
+     */
+    [Event(name="dragExit", type="org.apache.royale.events.DragEvent")]
+
+    /**
+     *  Indicates that a drop operation should be executed.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.9.7
+     */
+    [Event(name="dragDrop", type="org.apache.royale.events.DragEvent")]
+
+	/**
+	 *  The OutOfApplicationDropMouseController bead handles mouse events outside of the application
+	 *  looking for events from a drag/drop operation.
+	 *
+	 *  @royaleignoreimport org.apache.royale.core.IDragInitiator
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.9.7
+	 */
+	public class OutOfApplicationDropMouseController extends EventDispatcher implements IBead
+	{
+		/**
+		 *  constructor.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.7
+		 */
+		public function OutOfApplicationDropMouseController()
+		{
+		}
+
+		private var _strand:IStrand;
+
+		/**
+		 *  @copy org.apache.royale.core.IBead#strand
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.7
+		 *  @royaleignorecoercion org.apache.royale.events.IEventDispatcher
+		 */
+		public function set strand(value:IStrand):void
+		{
+			_strand = value;
+
+			COMPILE::SWF
+			{
+				DragEvent.init();
+			}
+			(_strand as IEventDispatcher).addEventListener(DragEvent.DRAG_MOVE, dragMoveHandler);
+		}
+
+		public function get strand():IStrand
+		{
+			return _strand;
+		}
+
+		private var listenersInitialized:Boolean;
+		private var draggingOutOfApp:Boolean;
+
+		public function acceptDragDrop(target:IUIBase, type:String):void
+		{
+			// TODO
+		}
+
+		/**
+		 *  @private
+		 */ 
+		private function dragMoveHandler(event:DragEvent):void
+		{
+			if (!listenersInitialized)
+			{
+				COMPILE::JS
+				{
+					(_strand as IRenderedObject).element.addEventListener("mouseleave", mouseLeaveHandler);
+				}
+				COMPILE::SWF
+				{
+					// TODO
+				}
+				listenersInitialized = true;
+			} else if (draggingOutOfApp)
+			{
+				draggingOutOfApp = false;
+				var dragEvent:DragEvent = new DragEvent("dragExit");
+				dispatchEvent(dragEvent);
+				Cursors.setCursor(_strand as IRenderedObject, Cursors.AUTO);
+			}
+
+		}
+
+		COMPILE::JS
+		private function mouseLeaveHandler(event:BrowserEvent):void
+		{
+			var dragEvent:DragEvent = new DragEvent("dragEnter");
+			dispatchEvent(dragEvent);
+			window.addEventListener("mouseup" , dragEndHandler);
+			Cursors.setCursor(_strand as IRenderedObject, Cursors.MOVE);
+			draggingOutOfApp = true;
+		}
+
+		COMPILE::JS
+		private function dragEndHandler(event:BrowserEvent):void
+		{
+			var dragEvent:DragEvent = new DragEvent("dragDrop");
+			dispatchEvent(dragEvent);
+			(_strand as IRenderedObject).element.removeEventListener("mouseleave", mouseLeaveHandler);
+			listenersInitialized = false;
+			draggingOutOfApp = false;
+			Cursors.setCursor(_strand as IRenderedObject, Cursors.AUTO);
+			// clean up drag image, etc.
+			var mouseEvent:MouseEvent = new MouseEvent(MouseEvent.MOUSE_UP);
+			(_strand as IEventDispatcher).dispatchEvent(mouseEvent);
+		}
+
+	}
+}


[royale-asjs] 02/02: This flag needs to be raised somewhere other than init

Posted by yi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 4a95681d456df7186daec4f5b1a0e936bd169eb4
Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
AuthorDate: Thu Dec 19 09:12:22 2019 +0200

    This flag needs to be raised somewhere other than init
---
 .../royale/org/apache/royale/html/beads/SingleSelectionDragSourceBead.as | 1 +
 1 file changed, 1 insertion(+)

diff --git a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/SingleSelectionDragSourceBead.as b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/SingleSelectionDragSourceBead.as
index dca8c12..fc77962 100644
--- a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/SingleSelectionDragSourceBead.as
+++ b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/SingleSelectionDragSourceBead.as
@@ -187,6 +187,7 @@ package org.apache.royale.html.beads
 			}
 
 			var newEvent:Event = new Event("start", false, true);
+			continueDragOperation = true;
 			dispatchEvent(newEvent);
 			if (newEvent.defaultPrevented) {
 				continueDragOperation = false;