You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by er...@apache.org on 2014/02/27 16:44:02 UTC

[7/7] git commit: [flex-asjs] [refs/heads/develop] - Implementation of the creation and registration of the 'click' event callback in FlexJS and SVG.

Implementation of the creation and registration of the 'click' event callback in FlexJS and SVG.

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/develop
Commit: dcbeeb823fa7f493e149a950b567fe4c9b4f2da6
Parents: 840bda9
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Thu Feb 27 12:38:25 2014 +0100
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Feb 27 16:43:38 2014 +0100

----------------------------------------------------------------------
 .../apache/flex/svg/staticControls/TextButton.js   | 17 +++++++++++++++++
 .../svg/staticControls/skins/TextButtonSkin.svg    |  4 ++--
 2 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/dcbeeb82/frameworks/js/FlexJS/src/org/apache/flex/svg/staticControls/TextButton.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/svg/staticControls/TextButton.js b/frameworks/js/FlexJS/src/org/apache/flex/svg/staticControls/TextButton.js
index 5dba453..96ac6d5 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/svg/staticControls/TextButton.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/svg/staticControls/TextButton.js
@@ -54,6 +54,23 @@ org.apache.flex.svg.staticControls.TextButton.prototype.createElement =
 
 
 /**
+ * @override
+ */
+org.apache.flex.svg.staticControls.TextButton.prototype.finalizeElement =
+    function() {
+  var listenersArray;
+  if (goog.events.hasListener(this.element, goog.events.EventType.CLICK)) {
+    listenersArray = goog.events.getListeners(this.element, goog.events.EventType.CLICK, false);
+
+    /* As we are assigning an actual function object instead of just the name,
+       make sure to use a unique name ('clickHandler') instead of a native 
+       name, like 'click' or 'onclick'. */
+    this.element.clickHandler = listenersArray[0].listener;
+  }
+};
+
+
+/**
  * @expose
  * @return {string} The text getter.
  */

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/dcbeeb82/frameworks/js/FlexJS/src/org/apache/flex/svg/staticControls/skins/TextButtonSkin.svg
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/svg/staticControls/skins/TextButtonSkin.svg b/frameworks/js/FlexJS/src/org/apache/flex/svg/staticControls/skins/TextButtonSkin.svg
index 097965d..7986725 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/svg/staticControls/skins/TextButtonSkin.svg
+++ b/frameworks/js/FlexJS/src/org/apache/flex/svg/staticControls/skins/TextButtonSkin.svg
@@ -48,7 +48,7 @@
 			labelElement.firstChild.nodeValue = labelStr;
 			
 			//Store callbacks
-			clickHandler = window.frameElement.attributes["onclick"].value;
+			clickHandler = window.frameElement.clickHandler;
 		}
 	
 		function handleMouseOver(event)
@@ -81,7 +81,7 @@
 		
 		function handleOnClick(evt)
 		{
-			top[clickHandler](evt,this);
+			clickHandler(evt,this);
 		}
 
 	]]></script>