This is an automated email from the ASF dual-hosted git repository. yishayw 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 43956a7f71 Emulation - make sure drop mouse events are dispatched from list based components 43956a7f71 is described below commit 43956a7f71d450a9fb4f6a45bc66d49e829abcac Author: Yishay Weiss <yishayj...@hotmail.com> AuthorDate: Sun Oct 16 14:07:44 2022 +0300 Emulation - make sure drop mouse events are dispatched from list based components --- .../beads/SingleSelectionDropTargetBead.as | 4 ++-- .../beads/TreeSingleSelectionDropTargetBead.as | 4 ++-- .../royale/mx/controls/listClasses/ListBase.as | 22 +++++++++++++++++++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/SingleSelectionDropTargetBead.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/SingleSelectionDropTargetBead.as index 3360e98fe9..30e94a218b 100644 --- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/SingleSelectionDropTargetBead.as +++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/SingleSelectionDropTargetBead.as @@ -24,6 +24,7 @@ package mx.controls.beads import org.apache.royale.core.IItemRendererOwnerView; import org.apache.royale.core.IChild; import org.apache.royale.core.IDataProviderModel; + import org.apache.royale.utils.getOrAddBeadByType; import org.apache.royale.core.IItemRenderer; import org.apache.royale.core.ItemRendererOwnerViewBead; import org.apache.royale.core.IParent; @@ -153,8 +154,7 @@ package mx.controls.beads { _strand = value; - _dropController = new DropMouseController(); - _strand.addBead(_dropController); + _dropController = getOrAddBeadByType(DropMouseController, value) as DropMouseController; _dropController.addEventListener(DragEvent.DRAG_ENTER, handleDragEnter); _dropController.addEventListener(DragEvent.DRAG_EXIT, handleDragExit); diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/TreeSingleSelectionDropTargetBead.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/TreeSingleSelectionDropTargetBead.as index aac294ce0b..b089f7eef9 100644 --- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/TreeSingleSelectionDropTargetBead.as +++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/TreeSingleSelectionDropTargetBead.as @@ -20,6 +20,7 @@ package mx.controls.beads { import mx.collections.IList; + import org.apache.royale.utils.getOrAddBeadByType; import org.apache.royale.core.DropType; import org.apache.royale.core.IBead; import org.apache.royale.core.IDataProviderModel; @@ -148,8 +149,7 @@ package mx.controls.beads { _strand = value; - _dropController = new DropMouseController(); - _strand.addBead(_dropController); + _dropController = getOrAddBeadByType(DropMouseController, value) as DropMouseController; _dropController.addEventListener(DragEvent.DRAG_ENTER, handleDragEnter); _dropController.addEventListener(DragEvent.DRAG_EXIT, handleDragExit); diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/ListBase.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/ListBase.as index 312e17e336..f94d2a4c42 100644 --- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/ListBase.as +++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/ListBase.as @@ -19,6 +19,7 @@ package mx.controls.listClasses { +import org.apache.royale.utils.getOrAddBeadByType; import mx.collections.ArrayCollection; import mx.collections.ICollectionView; import mx.collections.IList; @@ -60,6 +61,11 @@ import org.apache.royale.utils.loadBeadFromValuesManager; import mx.controls.dataGridClasses.DataGridListData; import mx.events.FlexEvent; import org.apache.royale.core.IHasLabelField; +import org.apache.royale.html.beads.controllers.DropMouseController; +import org.apache.royale.events.IEventDispatcher; +import org.apache.royale.utils.sendStrandEvent; +import mx.core.DragSource; +import org.apache.royale.events.DragEvent; use namespace mx_internal; @@ -955,9 +961,23 @@ use namespace mx_internal; // were made; these are just defaults extracted from CSS. loadBeadFromValuesManager(IDataProviderItemRendererMapper, "iDataProviderItemRendererMapper", this); loadBeadFromValuesManager(IItemRendererClassFactory, "iItemRendererClassFactory", this); + // Make sure list based components dispatch drop events to potential listeners + var dropMouseController:IEventDispatcher = getOrAddBeadByType(DropMouseController, this) as IEventDispatcher; + dropMouseController.addEventListener(org.apache.royale.events.DragEvent.DRAG_ENTER, handleDropControllerEvent); + dropMouseController.addEventListener(org.apache.royale.events.DragEvent.DRAG_EXIT, handleDropControllerEvent); + dropMouseController.addEventListener(org.apache.royale.events.DragEvent.DRAG_OVER, handleDropControllerEvent); + dropMouseController.addEventListener(org.apache.royale.events.DragEvent.DRAG_DROP, handleDropControllerEvent); dispatchEvent(new Event("initComplete")); } + + + private function handleDropControllerEvent(event:org.apache.royale.events.DragEvent):void + { + var dragInitiator:IUIComponent; // TODO... + var dragEvent:mx.events.DragEvent = new mx.events.DragEvent(event.type, false, true, dragInitiator, org.apache.royale.events.DragEvent.dragSource as DragSource); + dispatchEvent(dragEvent); + } /* * IItemRendererProvider @@ -1167,7 +1187,7 @@ use namespace mx_internal; * @playerversion AIR 1.1 * @productversion Flex 3 */ - public function hideDropFeedback(event:DragEvent):void + public function hideDropFeedback(event:mx.events.DragEvent):void { //To Do trace("hideDropFeedback is not implemented");