You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ha...@apache.org on 2019/12/15 08:13:00 UTC
[royale-asjs] branch develop updated: Fixed dragMove and dragEnd
events on source beads
This is an automated email from the ASF dual-hosted git repository.
harbs 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 904f59d Fixed dragMove and dragEnd events on source beads
new 7789fa0 Merge branch 'develop' of https://github.com/apache/royale-asjs into develop
904f59d is described below
commit 904f59d508d7c44dca9b911ed7252d5adf2ea89f
Author: Harbs <ha...@in-tools.com>
AuthorDate: Sun Dec 15 10:12:44 2019 +0200
Fixed dragMove and dragEnd events on source beads
---
.../html/beads/MultiSelectionDragSourceBead.as | 46 ++++++++++++----------
.../html/beads/SingleSelectionDragSourceBead.as | 40 +++++++++++--------
.../html/beads/controllers/DragMouseController.as | 28 +++++++++++--
3 files changed, 74 insertions(+), 40 deletions(-)
diff --git a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/MultiSelectionDragSourceBead.as b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/MultiSelectionDragSourceBead.as
index a49e4c4..ac2e366 100644
--- a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/MultiSelectionDragSourceBead.as
+++ b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/MultiSelectionDragSourceBead.as
@@ -19,32 +19,19 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.royale.html.beads
{
- import org.apache.royale.core.IStrandWithModel;
import org.apache.royale.collections.ArrayList;
import org.apache.royale.core.IBead;
import org.apache.royale.core.IChild;
- import org.apache.royale.core.IMultiSelectionModel;
- import org.apache.royale.core.IDocument;
import org.apache.royale.core.IDragInitiator;
import org.apache.royale.core.IItemRenderer;
- import org.apache.royale.core.ILayoutHost;
- import org.apache.royale.core.IItemRendererParent;
- import org.apache.royale.core.IParent;
- import org.apache.royale.core.ISelectionModel;
+ import org.apache.royale.core.IMultiSelectionModel;
import org.apache.royale.core.IStrand;
- import org.apache.royale.core.IUIBase;
+ import org.apache.royale.core.IStrandWithModel;
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.geom.Point;
- import org.apache.royale.geom.Rectangle;
- import org.apache.royale.html.Group;
- import org.apache.royale.html.Label;
import org.apache.royale.html.beads.controllers.DragMouseController;
- import org.apache.royale.html.supportClasses.DataItemRenderer;
- import org.apache.royale.utils.PointUtils;
- import org.apache.royale.utils.UIUtils;
import org.apache.royale.utils.getParentOrSelfByType;
/**
@@ -82,8 +69,27 @@ package org.apache.royale.html.beads
*/
[Event(name="complete", type="org.apache.royale.events.Event")]
+ /**
+ * The dragMove event is dispatched while the drag action moves.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ [Event(name="dragMove", type="org.apache.royale.events.DragEvent")]
/**
+ * The dragEnd event is dispatched while the drag action stops.
+ * This is dispatched even when the drag event is aborted.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ [Event(name="dragEnd", type="org.apache.royale.events.DragEvent")]
+ /**
* The MultiSelectionDragSourceBead brings drag capability to single-selection List components.
* By adding this bead, a user can drag a row of the List to a new location within the list. This bead
* should be used in conjunction with SingleSelectionDropTargetBead.
@@ -147,9 +153,9 @@ package org.apache.royale.html.beads
_dragController = new DragMouseController();
_strand.addBead(_dragController);
- IEventDispatcher(_strand).addEventListener(DragEvent.DRAG_START, handleDragStart);
- IEventDispatcher(_strand).addEventListener(DragEvent.DRAG_MOVE, handleDragMove);
- IEventDispatcher(_strand).addEventListener(DragEvent.DRAG_END, handleDragEnd);
+ _dragController.addEventListener(DragEvent.DRAG_START, handleDragStart);
+ _dragController.addEventListener(DragEvent.DRAG_MOVE, handleDragMove);
+ _dragController.addEventListener(DragEvent.DRAG_END, handleDragEnd);
}
/**
@@ -208,7 +214,7 @@ package org.apache.royale.html.beads
*/
protected function handleDragMove(event:DragEvent):void
{
- // ignored for now
+ dispatchEvent(event);
}
/**
@@ -216,7 +222,7 @@ package org.apache.royale.html.beads
*/
protected function handleDragEnd(event:DragEvent):void
{
- // ignored for now
+ dispatchEvent(event);
}
/* IDragInitiator */
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..0723da7 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
@@ -22,27 +22,16 @@ package org.apache.royale.html.beads
import org.apache.royale.core.IBead;
import org.apache.royale.core.IChild;
import org.apache.royale.core.IDataProviderModel;
- import org.apache.royale.core.IDocument;
import org.apache.royale.core.IDragInitiator;
import org.apache.royale.core.IItemRenderer;
import org.apache.royale.core.ILayoutHost;
- import org.apache.royale.core.IItemRendererParent;
import org.apache.royale.core.IParent;
import org.apache.royale.core.ISelectionModel;
import org.apache.royale.core.IStrand;
- import org.apache.royale.core.IUIBase;
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.geom.Point;
- import org.apache.royale.geom.Rectangle;
- import org.apache.royale.html.Group;
- import org.apache.royale.html.Label;
import org.apache.royale.html.beads.controllers.DragMouseController;
- import org.apache.royale.html.supportClasses.DataItemRenderer;
- import org.apache.royale.utils.PointUtils;
- import org.apache.royale.utils.UIUtils;
import org.apache.royale.utils.getParentOrSelfByType;
/**
@@ -80,8 +69,27 @@ package org.apache.royale.html.beads
*/
[Event(name="complete", type="org.apache.royale.events.Event")]
+ /**
+ * The dragMove event is dispatched while the drag action moves.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ [Event(name="dragMove", type="org.apache.royale.events.DragEvent")]
/**
+ * The dragEnd event is dispatched while the drag action stops.
+ * This is dispatched even when the drag event is aborted.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ [Event(name="dragEnd", type="org.apache.royale.events.DragEvent")]
+ /**
* The SingleSelectionDragSourceBead brings drag capability to single-selection List components.
* By adding this bead, a user can drag a row of the List to a new location within the list. This bead
* should be used in conjunction with SingleSelectionDropTargetBead.
@@ -145,9 +153,9 @@ package org.apache.royale.html.beads
_dragController = new DragMouseController();
_strand.addBead(_dragController);
- IEventDispatcher(_strand).addEventListener(DragEvent.DRAG_START, handleDragStart);
- IEventDispatcher(_strand).addEventListener(DragEvent.DRAG_MOVE, handleDragMove);
- IEventDispatcher(_strand).addEventListener(DragEvent.DRAG_END, handleDragEnd);
+ _dragController.addEventListener(DragEvent.DRAG_START, handleDragStart);
+ _dragController.addEventListener(DragEvent.DRAG_MOVE, handleDragMove);
+ _dragController.addEventListener(DragEvent.DRAG_END, handleDragEnd);
}
private var _dragSourceIndex:int = -1;
@@ -198,7 +206,7 @@ package org.apache.royale.html.beads
*/
protected function handleDragMove(event:DragEvent):void
{
- // ignored for now
+ dispatchEvent(event);
}
/**
@@ -206,7 +214,7 @@ package org.apache.royale.html.beads
*/
protected function handleDragEnd(event:DragEvent):void
{
- // ignored for now
+ dispatchEvent(event);
}
/* IDragInitiator */
diff --git a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/controllers/DragMouseController.as b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/controllers/DragMouseController.as
index d895dfb..7772459 100644
--- a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/controllers/DragMouseController.as
+++ b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/controllers/DragMouseController.as
@@ -223,9 +223,19 @@ package org.apache.royale.html.beads.controllers
private function dragMouseDownHandler(event:MouseEvent):void
{
// trace("DRAG-MOUSE: dragMouseDown");
- IUIBase(_strand).topMostEventDispatcher.addEventListener(MouseEvent.MOUSE_MOVE, dragMouseMoveHandler);
- IUIBase(_strand).topMostEventDispatcher.addEventListener(MouseEvent.MOUSE_UP, dragMouseUpHandler);
- IUIBase(_strand).topMostEventDispatcher.addEventListener(MouseEvent.CLICK, dragMouseUpHandler);
+ (_strand as IUIBase).topMostEventDispatcher.addEventListener(MouseEvent.MOUSE_MOVE, dragMouseMoveHandler);
+ (_strand as IUIBase).topMostEventDispatcher.addEventListener(MouseEvent.CLICK, dragMouseUpHandler);
+ COMPILE::SWF
+ {
+ (_strand as IUIBase).topMostEventDispatcher.addEventListener(MouseEvent.MOUSE_UP, dragMouseUpHandler);
+ }
+ /**
+ * In browser, we need to listen to window to get mouseup events outside the window
+ */
+ COMPILE::JS
+ {
+ window.addEventListener(MouseEvent.MOUSE_UP, dragMouseUpHandler);
+ }
mouseDownX = event.screenX;
mouseDownY = event.screenY;
event.preventDefault();
@@ -343,8 +353,18 @@ package org.apache.royale.html.beads.controllers
dragImage = null;
IUIBase(_strand).topMostEventDispatcher.removeEventListener(MouseEvent.MOUSE_MOVE, dragMouseMoveHandler);
- IUIBase(_strand).topMostEventDispatcher.removeEventListener(MouseEvent.MOUSE_UP, dragMouseUpHandler);
IUIBase(_strand).topMostEventDispatcher.removeEventListener(MouseEvent.CLICK, dragMouseUpHandler);
+
+ COMPILE::SWF
+ {
+ (_strand as IUIBase).topMostEventDispatcher.removeEventListener(MouseEvent.MOUSE_UP, dragMouseUpHandler);
+ }
+
+ COMPILE::JS
+ {
+ window.removeEventListener(MouseEvent.MOUSE_UP, dragMouseUpHandler);
+ }
+
}
}