royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yish...@apache.org
Subject [royale-asjs] branch EventConverter updated: Export cross browser support to a bead so core implementation stays efficient and works on non-IE browsers
Date Thu, 15 Mar 2018 08:37:55 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/EventConverter by this push:
     new 429032f  Export cross browser support to a bead so core implementation stays efficient
and works on non-IE browsers
429032f is described below

commit 429032f75d4e48988980fda8e171c6c6e6b1e7bb
Author: DESKTOP-RH4S838\Yishay <yishayjobs@hotmail.com>
AuthorDate: Thu Mar 15 10:36:44 2018 +0200

    Export cross browser support to a bead so core implementation stays
    efficient and works on non-IE browsers
---
 .../Basic/src/main/resources/basic-manifest.xml    |  1 +
 .../org/apache/royale/core/HTMLElementWrapper.as   | 23 +++---
 .../beads/CrossBrowserFireListenerOverrideBead.as  | 93 ++++++++++++++++++++++
 3 files changed, 106 insertions(+), 11 deletions(-)

diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index a201ea1..dbff20e 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -87,6 +87,7 @@
     <component id="ListView" class="org.apache.royale.html.beads.ListView"/>
     <component id="AccordionView" class="org.apache.royale.html.beads.AccordionView"/>
     <component id="CenterElement" class="org.apache.royale.html.beads.CenterElement"/>
+    <component id="CrossBrowserFireListenerOverrideBead" class="org.apache.royale.html.beads.CrossBrowserFireListenerOverrideBead"
/>
     <component id="AccessibilityAltBead" class="org.apache.royale.html.beads.AccessibilityAltBead"
/>
     <component id="DataGridColumnChangePropagator" class="org.apache.royale.html.beads.DataGridColumnChangePropagator"
/>
     <component id="DataGridColumnForceChangePropagator" class="org.apache.royale.html.beads.DataGridColumnForceChangePropagator"
/>
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/HTMLElementWrapper.as
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/HTMLElementWrapper.as
index 7aa8a0b..7228fbc 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/HTMLElementWrapper.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/HTMLElementWrapper.as
@@ -71,17 +71,18 @@ package org.apache.royale.core
 		{
             var e:IBrowserEvent;
             var nativeEvent:Object = eventObject.getBrowserEvent();
-			var constructorName:String = nativeEvent.constructor.toString();
-			if (constructorName.indexOf('KeyboardEvent') > -1)
-			{
-				e = KeyboardEventConverter.convert(nativeEvent);
-			} else if (constructorName.indexOf('MouseEvent') > -1)
-			{
-				e = MouseEventConverter.convert(nativeEvent);
-			} else
-			{
-				e = new org.apache.royale.events.BrowserEvent();
-			}
+            switch(nativeEvent.constructor.name)
+            {
+                case "KeyboardEvent":
+                    e = KeyboardEventConverter.convert(nativeEvent);
+                    break;
+                case "MouseEvent":
+                    e = MouseEventConverter.convert(nativeEvent);
+                    break;
+                default:
+                    e = new org.apache.royale.events.BrowserEvent();
+                    break;
+            }
 
 			e.wrapEvent(eventObject);
 			return HTMLElementWrapper.googFireListener(listener, e);
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/CrossBrowserFireListenerOverrideBead.as
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/CrossBrowserFireListenerOverrideBead.as
new file mode 100644
index 0000000..06de46f
--- /dev/null
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/CrossBrowserFireListenerOverrideBead.as
@@ -0,0 +1,93 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.core.IBead;
+    import org.apache.royale.core.IStrand;
+	import org.apache.royale.core.HTMLElementWrapper;
+    COMPILE::JS  
+	{
+        import goog.events;
+        import goog.events.EventTarget;
+        import goog.events.BrowserEvent;
+        import org.apache.royale.events.IBrowserEvent;
+        import org.apache.royale.events.utils.KeyboardEventConverter;
+        import org.apache.royale.events.utils.MouseEventConverter;
+	}
+    /**
+     *  Overrides default HTMLElementWrapper implementation to make sure events are converted
on all browsers
+	 *  including IE. 
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.92
+     */
+	public class CrossBrowserFireListenerOverrideBead implements IBead
+	{
+        /**
+         *  Constructor.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.92
+         */
+		public function CrossBrowserFireListenerOverrideBead()
+		{
+			super();
+		}
+        
+        /**
+         *  @copy org.apache.royale.core.IBead#strand
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.92
+         */
+        public function set strand(value:IStrand):void
+        {
+			COMPILE::JS 
+			{
+				goog.events.fireListener = CrossBrowserFireListenerOverrideBead.fireListenerOverride;
+			}
+        }    
+
+		COMPILE::JS
+		static protected function fireListenerOverride(listener:Object, eventObject:goog.events.BrowserEvent):Boolean
+		{
+            var e:IBrowserEvent;
+            var nativeEvent:Object = eventObject.getBrowserEvent();
+			var constructorName:String = nativeEvent.constructor.toString();
+			if (constructorName.indexOf('KeyboardEvent') > -1)
+			{
+				e = KeyboardEventConverter.convert(nativeEvent);
+			} else if (constructorName.indexOf('MouseEvent') > -1)
+			{
+				e = MouseEventConverter.convert(nativeEvent);
+			} else
+			{
+				e = new org.apache.royale.events.BrowserEvent();
+			}
+
+			e.wrapEvent(eventObject);
+			return HTMLElementWrapper.googFireListener(listener, e);
+		}
+    }
+}

-- 
To stop receiving notification emails like this one, please contact
yishayw@apache.org.

Mime
View raw message