flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [1/4] git commit: [flex-asjs] [refs/heads/develop] - change where we listen for events so we listen to the right place
Date Fri, 28 Aug 2015 20:53:49 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 417fc3cff -> a29787a0a


change where we listen for events so we listen to the right place


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

Branch: refs/heads/develop
Commit: 83521ab80e7ad933d2054ed2d670ac39541c35ed
Parents: 417fc3c
Author: Alex Harui <aharui@apache.org>
Authored: Fri Aug 28 13:52:07 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Fri Aug 28 13:52:07 2015 -0700

----------------------------------------------------------------------
 .../src/org/apache/flex/events/ElementEvents.js |  5 ++
 .../org/apache/flex/events/EventDispatcher.js   | 80 ++++++++++----------
 2 files changed, 45 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83521ab8/frameworks/projects/Core/js/src/org/apache/flex/events/ElementEvents.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/js/src/org/apache/flex/events/ElementEvents.js b/frameworks/projects/Core/js/src/org/apache/flex/events/ElementEvents.js
index 1f91abe..ce46b37 100644
--- a/frameworks/projects/Core/js/src/org/apache/flex/events/ElementEvents.js
+++ b/frameworks/projects/Core/js/src/org/apache/flex/events/ElementEvents.js
@@ -36,6 +36,11 @@ org.apache.flex.events.ElementEvents.prototype.FLEXJS_CLASS_INFO =
  * @type {Object}
  */
 org.apache.flex.events.ElementEvents.elementEvents = {
+  'click': 1,
+  'change': 1,
+  'keyup': 1,
+  'keydown': 1,
+  'load': 1,
   'mouseover': 1,
   'mouseout': 1,
   'mouseup': 1,

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83521ab8/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js b/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js
index a26028a..54e48ef 100644
--- a/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js
+++ b/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js
@@ -44,29 +44,59 @@ org.apache.flex.events.EventDispatcher.prototype.FLEXJS_CLASS_INFO =
 
 
 /**
- * @override
- * @export
+ * @private
+ * @param {string} type The event name.
+ * @return {goog.events.EventTarget} The target.
  */
-org.apache.flex.events.EventDispatcher.prototype.addEventListener =
-    function(type, handler, opt_capture, opt_handlerScope) {
-  var source;
-
+org.apache.flex.events.EventDispatcher.prototype.getActualDispatcher_ = function(type) {
   /**
    *  A bit of a hack, but for 'native' HTML element based controls, we
    *  want to listen to the 'native' events from the element; for other
    *  types of controls, we listen to 'custom' events.
    */
-  source = this;
+  var source = this;
+  /*
   if (this.element && this.element.nodeName &&
       this.element.nodeName.toLowerCase() !== 'div' &&
       // we don't use any native img events right now, we wrapthem
       this.element.nodeName.toLowerCase() !== 'img' &&
       this.element.nodeName.toLowerCase() !== 'body') {
     source = this.element;
-  } else if (org.apache.flex.events.ElementEvents.elementEvents[type]) {
+  } else */ if (org.apache.flex.events.ElementEvents.elementEvents[type]) {
     // mouse and keyboard events also dispatch off the element.
     source = this.element;
   }
+  return source;
+};
+
+
+/**
+ * @override
+ * @export
+ */
+org.apache.flex.events.EventDispatcher.prototype.dispatchEvent = function(e) {
+  var t;
+  if (typeof(e) === 'string')
+    t = e;
+  else
+    t = e.type;
+  var source = this.getActualDispatcher_(t);
+  if (source == this)
+    return org.apache.flex.events.EventDispatcher.base(this, 'dispatchEvent', e);
+
+  return source.dispatchEvent(e);
+};
+
+
+/**
+ * @override
+ * @export
+ */
+org.apache.flex.events.EventDispatcher.prototype.addEventListener =
+    function(type, handler, opt_capture, opt_handlerScope) {
+  var source;
+
+  source = this.getActualDispatcher_(type);
 
   goog.events.listen(source, type, handler);
 };
@@ -80,22 +110,7 @@ org.apache.flex.events.EventDispatcher.prototype.removeEventListener =
     function(type, handler, opt_capture, opt_handlerScope) {
   var source;
 
-  /**
-   *  A bit of a hack, but for 'native' HTML element based controls, we
-   *  want to listen to the 'native' events from the element; for other
-   *  types of controls, we listen to 'custom' events.
-   */
-  source = this;
-  if (this.element && this.element.nodeName &&
-      this.element.nodeName.toLowerCase() !== 'div' &&
-      // we don't use any native img events right now, we wrapthem
-      this.element.nodeName.toLowerCase() !== 'img' &&
-      this.element.nodeName.toLowerCase() !== 'body') {
-    source = this.element;
-  } else if (org.apache.flex.events.ElementEvents.elementEvents[type]) {
-    // mouse and keyboard events also dispatch off the element.
-    source = this.element;
-  }
+  source = this.getActualDispatcher_(type);
 
   goog.events.unlisten(source, type, handler);
 };
@@ -110,22 +125,7 @@ org.apache.flex.events.EventDispatcher.prototype.hasEventListener =
     function(type) {
   var source;
 
-  /**
-   *  A bit of a hack, but for 'native' HTML element based controls, we
-   *  want to listen to the 'native' events from the element; for other
-   *  types of controls, we listen to 'custom' events.
-   */
-  source = this;
-  if (this.element && this.element.nodeName &&
-      this.element.nodeName.toLowerCase() !== 'div' &&
-      // we don't use any native img events right now, we wrapthem
-      this.element.nodeName.toLowerCase() !== 'img' &&
-      this.element.nodeName.toLowerCase() !== 'body') {
-    source = this.element;
-  } else if (org.apache.flex.events.ElementEvents.elementEvents[type]) {
-    // mouse and keyboard events also dispatch off the element.
-    source = this.element;
-  }
+  source = this.getActualDispatcher_(type);
 
   return goog.events.hasListener(source, type);
 };


Mime
View raw message