You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2015/11/11 01:29:57 UTC

[2/4] git commit: [flex-asjs] [refs/heads/core_js_to_as] - insert DragEventBase so more of DragEvent cross-compiles without duplication

insert DragEventBase so more of DragEvent cross-compiles without duplication


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/559a1ad4
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/559a1ad4
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/559a1ad4

Branch: refs/heads/core_js_to_as
Commit: 559a1ad4e1b4b75469790e7eebaffc274ee676d0
Parents: 110c96f
Author: Alex Harui <ah...@apache.org>
Authored: Tue Nov 10 15:24:04 2015 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Nov 10 16:29:48 2015 -0800

----------------------------------------------------------------------
 .../as/src/org/apache/flex/events/DragEvent.as  | 58 +++++++++++++++-----
 .../src/org/apache/flex/events/DragEventBase.as | 47 ++++++++++++++++
 2 files changed, 91 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/559a1ad4/frameworks/projects/DragDrop/as/src/org/apache/flex/events/DragEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/DragDrop/as/src/org/apache/flex/events/DragEvent.as b/frameworks/projects/DragDrop/as/src/org/apache/flex/events/DragEvent.as
index 406ad9d..895fb7f 100644
--- a/frameworks/projects/DragDrop/as/src/org/apache/flex/events/DragEvent.as
+++ b/frameworks/projects/DragDrop/as/src/org/apache/flex/events/DragEvent.as
@@ -19,7 +19,10 @@
 package org.apache.flex.events
 {
     import org.apache.flex.core.IDragInitiator;
-    import org.apache.flex.events.MouseEvent;
+    COMPILE::JS
+    {
+        import window.MouseEvent;
+    }
     
 	/**
 	 *  Drag and Drop Events.
@@ -29,7 +32,7 @@ package org.apache.flex.events
      *  @playerversion AIR 2.6
      *  @productversion FlexJS 0.0
 	 */
-	public class DragEvent extends MouseEvent
+	public class DragEvent extends DragEventBase
 	{
         /**
          *  The <code>DragEvent.DRAG_START</code> constant defines the value of the 
@@ -268,7 +271,14 @@ package org.apache.flex.events
          */
 		public function DragEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
 		{
-			super(type, bubbles, cancelable);
+            COMPILE::AS3
+            {
+                super(type, bubbles, cancelable);                    
+            }
+            COMPILE::JS
+            {
+                this.type = type;
+            }
 		}
 
         /**
@@ -282,19 +292,32 @@ package org.apache.flex.events
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
+         *  @flexjsignorecoercion org.apache.flex.events.DragEvent
          */
         public static function createDragEvent(type:String, event:MouseEvent):DragEvent
         {
-            var de:DragEvent = new DragEvent(type, true, true);
-            de.localX = event.localX;
-            de.localY = event.localY;
-            de.altKey = event.altKey;
-            de.ctrlKey = event.ctrlKey;
-            de.shiftKey = event.shiftKey;
-            de.buttonDown = event.buttonDown;
-            de.delta = event.delta;
-            de.relatedObject = event.relatedObject;
-            return de;
+            COMPILE::AS3
+            {
+                var de:DragEvent = new DragEvent(type, true, true);
+                de.localX = event.localX;
+                de.localY = event.localY;
+                de.altKey = event.altKey;
+                de.ctrlKey = event.ctrlKey;
+                de.shiftKey = event.shiftKey;
+                de.buttonDown = event.buttonDown;
+                de.delta = event.delta;
+                de.relatedObject = event.relatedObject;
+                return de;                    
+            }
+            COMPILE::JS
+            {
+                var out:MouseEvent = new MouseEvent(type);
+                out.initMouseEvent(type, true, true,
+                    e.view, e.detail, e.screenX, e.screenY,
+                    e.clientX, e.clientY, e.ctrlKey, e.altKey,
+                    e.shiftKey, e.metaKey, e.button, e.relatedTarget);
+                return out as DragEvent;
+            }
         }
         
         
@@ -311,7 +334,14 @@ package org.apache.flex.events
          */
         public static function dispatchDragEvent(event:DragEvent, target:IEventDispatcher):void
         {
-            target.dispatchEvent(event);
+            COMPILE::AS3
+            {
+                target.dispatchEvent(event);                    
+            }
+            COMPILE::JS
+            {
+                target.element.dispatchEvent(event);
+            }
         }
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/559a1ad4/frameworks/projects/DragDrop/as/src/org/apache/flex/events/DragEventBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/DragDrop/as/src/org/apache/flex/events/DragEventBase.as b/frameworks/projects/DragDrop/as/src/org/apache/flex/events/DragEventBase.as
new file mode 100644
index 0000000..8f0aa44
--- /dev/null
+++ b/frameworks/projects/DragDrop/as/src/org/apache/flex/events/DragEventBase.as
@@ -0,0 +1,47 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.flex.events
+{
+    COMPILE::AS3
+    {
+        import org.apache.flex.events.MouseEvent;
+    }
+    COMPILE::JS
+    {
+        import goog.events.BrowserEvent;
+    }
+    
+	/**
+	 *  Drag and Drop Events.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion FlexJS 0.0
+	 */
+    COMPILE::AS3
+	public class DragEventBase extends MouseEvent
+	{
+    }
+
+    COMPILE::JS
+    public class DragEventBase extends BrowserEvent
+    {
+    }
+}
\ No newline at end of file