flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject [02/23] flex-asjs git commit: More-or-less working, but it does not seem to work as well as BrowserEvents. Not sure why…
Date Sun, 30 Jul 2017 20:50:59 GMT
More-or-less working, but it does not seem to work as well as BrowserEvents.
Not sure why…


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

Branch: refs/heads/develop
Commit: 26212ebfe42d1eb3fe0b5b91557b0edf2a09b509
Parents: a6cecd3
Author: Harbs <harbs@in-tools.com>
Authored: Wed Jul 19 23:36:38 2017 +0300
Committer: Harbs <harbs@in-tools.com>
Committed: Wed Jul 19 23:36:38 2017 +0300

----------------------------------------------------------------------
 .../org/apache/flex/core/HTMLElementWrapper.as  |  9 ++--
 .../projects/Core/src/main/flex/CoreClasses.as  |  2 +-
 .../org/apache/flex/events/KeyboardEvent.as     | 30 ++++++++++-
 .../flex/org/apache/flex/events/MouseEvent.as   | 55 +++++++++++++++++++-
 .../flex/events/utils/MouseEventConverter.as    | 22 ++++++--
 5 files changed, 107 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/26212ebf/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/HTMLElementWrapper.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/HTMLElementWrapper.as
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/HTMLElementWrapper.as
index 629ffd8..8bd93b9 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/HTMLElementWrapper.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/HTMLElementWrapper.as
@@ -27,6 +27,7 @@ package org.apache.flex.core
     {
         import org.apache.flex.events.Event;        
         import org.apache.flex.events.BrowserEvent;
+        import org.apache.flex.events.IBrowserEvent;
         import org.apache.flex.events.ElementEvents;
         import org.apache.flex.events.EventDispatcher;
         import goog.events;
@@ -35,6 +36,8 @@ package org.apache.flex.core
         import org.apache.flex.events.KeyboardEvent;
         import org.apache.flex.events.MouseEvent;
         import goog.events.BrowserEvent;
+        import org.apache.flex.events.utils.KeyboardEventConverter;
+        import org.apache.flex.events.utils.MouseEventConverter;
     }
 
     COMPILE::SWF
@@ -65,13 +68,13 @@ package org.apache.flex.core
 		static public function fireListenerOverride(listener:Object, eventObject:goog.events.BrowserEvent):Boolean
 		{
             var e:IBrowserEvent;
-            switch(eventObject.event_.constructor.name)
+            switch(eventObject["event_"].constructor.name)
             {
                 case "KeyboardEvent":
-                    e = new KeyboardEvent();
+                    e = KeyboardEventConverter.convert(eventObject["event_"]);
                     break;
                 case "MouseEvent":
-                    e = new MouseEvent();
+                    e = MouseEventConverter.convert(eventObject["event_"]);
                     break;
                 default:
                     e = new org.apache.flex.events.BrowserEvent();

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/26212ebf/frameworks/projects/Core/src/main/flex/CoreClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/CoreClasses.as b/frameworks/projects/Core/src/main/flex/CoreClasses.as
index e062a8b..fd6c8a2 100644
--- a/frameworks/projects/Core/src/main/flex/CoreClasses.as
+++ b/frameworks/projects/Core/src/main/flex/CoreClasses.as
@@ -131,10 +131,10 @@ internal class CoreClasses
 	import org.apache.flex.events.MouseEvent; MouseEvent;
 	import org.apache.flex.events.KeyboardEvent; KeyboardEvent;
 	import org.apache.flex.events.utils.KeyboardEventConverter; KeyboardEventConverter;
+	import org.apache.flex.events.utils.MouseEventConverter; MouseEventConverter;
 	COMPILE::SWF
 	{
 	    import org.apache.flex.core.StageProxy; StageProxy;
-		import org.apache.flex.events.utils.MouseEventConverter; MouseEventConverter;
 	}
 	import org.apache.flex.events.utils.KeyConverter; KeyConverter;
 	import org.apache.flex.events.DetailEvent; DetailEvent;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/26212ebf/frameworks/projects/Core/src/main/flex/org/apache/flex/events/KeyboardEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/events/KeyboardEvent.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/events/KeyboardEvent.as
index fbb4a79..b89dbff 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/events/KeyboardEvent.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/events/KeyboardEvent.as
@@ -22,7 +22,9 @@ package org.apache.flex.events
     {
         import goog.events.BrowserEvent;
     }
-    public class KeyboardEvent extends Event
+    import org.apache.flex.events.IBrowserEvent;
+
+    public class KeyboardEvent extends Event implements IBrowserEvent
     {
         COMPILE::SWF
         public static const KEY_DOWN:String = "keyDown";
@@ -139,6 +141,32 @@ package org.apache.flex.events
 		}
 
         /**
+         * @langversion 3.0
+         * @playerversion Flash 10.2
+         * @playerversion AIR 2.6
+         * @productversion FlexJS 0.9
+         */
+        COMPILE::JS
+		override public function stopImmediatePropagation():void
+		{
+            if(wrappedEvent)
+			    wrappedEvent["event_"].stopImmediatePropagation();
+		}
+
+        /**
+         * @langversion 3.0
+         * @playerversion Flash 10.2
+         * @playerversion AIR 2.6
+         * @productversion FlexJS 0.9
+         */
+        COMPILE::JS
+		override public function stopPropagation():void
+		{
+            if(wrappedEvent)
+			    wrappedEvent.stopPropagation();
+		}
+
+        /**
          * Create a copy/clone of the KeyboardEvent object.
          *
          * @langversion 3.0

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/26212ebf/frameworks/projects/Core/src/main/flex/org/apache/flex/events/MouseEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/events/MouseEvent.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/events/MouseEvent.as
index 6414042..8231e20 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/events/MouseEvent.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/events/MouseEvent.as
@@ -34,6 +34,7 @@ package org.apache.flex.events
     import org.apache.flex.core.IFlexJSElement;
     import org.apache.flex.geom.Point;
     import org.apache.flex.utils.PointUtils;
+    import org.apache.flex.events.IBrowserEvent;
 
 
 	/**
@@ -202,7 +203,7 @@ package org.apache.flex.events
 	}
 
 	COMPILE::JS
-	public class MouseEvent extends Event implements IFlexJSEvent
+	public class MouseEvent extends Event implements IFlexJSEvent, IBrowserEvent
 	{
 		private static function platformConstant(s:String):String
 		{
@@ -292,7 +293,34 @@ package org.apache.flex.events
 		public var ctrlKey:Boolean;
 		public var altKey:Boolean;
 		public var shiftKey:Boolean;
-		public var buttonDown:Boolean;
+		private var _buttons:int = -1;
+		public function get buttonDown():Boolean
+		{
+			if(_buttons > -1)
+				return _buttons == 1;
+			if(!wrappedEvent)
+				return false;
+			var ev:* = wrappedEvent.event_;
+			//Safari does not yet support buttons
+			if ('buttons' in ev)
+				_buttons = ev["buttons"];
+			else
+				_buttons = ev["which"];
+			return _buttons == 1;
+		}
+		public function set buttonDown(value:Boolean):void
+		{
+			_buttons = value ? 1 : 0;
+		}
+
+		public function get buttons():int
+		{
+			return _buttons;
+		}
+		public function set buttons(value:int):void
+		{
+			_buttons = value;
+		}
 		public var delta:int;
 		public var commandKey:Boolean;
 		public var controlKey:Boolean;
@@ -464,6 +492,29 @@ package org.apache.flex.events
                 buttonDown, delta
             /* got errors for commandKey, commandKey, controlKey, clickCount*/);
         }
+        /**
+         * @langversion 3.0
+         * @playerversion Flash 10.2
+         * @playerversion AIR 2.6
+         * @productversion FlexJS 0.9
+         */
+		override public function stopImmediatePropagation():void
+		{
+            if(wrappedEvent)
+			    wrappedEvent["event_"].stopImmediatePropagation();
+		}
+
+        /**
+         * @langversion 3.0
+         * @playerversion Flash 10.2
+         * @playerversion AIR 2.6
+         * @productversion FlexJS 0.9
+         */
+		override public function stopPropagation():void
+		{
+            if(wrappedEvent)
+			    wrappedEvent.stopPropagation();
+		}
 
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/26212ebf/frameworks/projects/Core/src/main/flex/org/apache/flex/events/utils/MouseEventConverter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/events/utils/MouseEventConverter.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/events/utils/MouseEventConverter.as
index 039d183..de3fecd 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/events/utils/MouseEventConverter.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/events/utils/MouseEventConverter.as
@@ -17,10 +17,12 @@
 //
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.events.utils
-{	
-    import flash.events.Event;
-    import flash.events.IEventDispatcher;
-    import flash.events.MouseEvent;
+{	COMPILE::SWF
+    {
+        import flash.events.Event;
+        import flash.events.IEventDispatcher;
+        import flash.events.MouseEvent;
+    }
     
     import org.apache.flex.events.MouseEvent;
     import org.apache.flex.events.utils.IHandlesOriginalEvent;
@@ -172,4 +174,16 @@ package org.apache.flex.events.utils
                 target.addEventListener(eventType, eventHandler, false, 9999);
         }
     }
+    COMPILE::JS
+	public class MouseEventConverter
+	{
+        public static function convert(oldEv:MouseEvent):org.apache.flex.events.MouseEvent
+        {
+            return new org.apache.flex.events.MouseEvent(oldEv.type, true, false,
+								   oldEv.clientX, oldEv.clientY,
+								   null,
+								   oldEv.ctrlKey, oldEv.altKey, oldEv.shiftKey);
+        }
+    }
+
 }


Mime
View raw message