You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ca...@apache.org on 2013/05/03 01:56:11 UTC

[8/9] git commit: [flex-asjs] [refs/heads/develop] - fix createjs checkbox, now working properly

fix createjs checkbox, now working properly


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

Branch: refs/heads/develop
Commit: a528433fac7328f1559ca9bb2ce6a22d20e40524
Parents: 44e73e5
Author: Carlos Rovira <ca...@apache.org>
Authored: Fri May 3 01:54:53 2013 +0200
Committer: Carlos Rovira <ca...@apache.org>
Committed: Fri May 3 01:54:53 2013 +0200

----------------------------------------------------------------------
 .../flex/createjs/staticControls/CheckBox.js       |   20 ++++++++++++--
 1 files changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a528433f/frameworks/js/FlexJS/src/org/apache/flex/createjs/staticControls/CheckBox.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/createjs/staticControls/CheckBox.js b/frameworks/js/FlexJS/src/org/apache/flex/createjs/staticControls/CheckBox.js
index f460541..5a2ae5c 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/createjs/staticControls/CheckBox.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/createjs/staticControls/CheckBox.js
@@ -30,7 +30,6 @@ goog.inherits(
 org.apache.flex.createjs.staticControls.CheckBox.prototype.checkMark = null;
 org.apache.flex.createjs.staticControls.CheckBox.prototype.checkMarkBackground = null;
 org.apache.flex.createjs.staticControls.CheckBox.prototype.checkBoxLabel = null;
-org.apache.flex.createjs.staticControls.CheckBox.prototype.selected = false;
 
 /**
  * @override
@@ -42,7 +41,11 @@ org.apache.flex.createjs.staticControls.CheckBox.prototype.addToParent = functio
 	this.checkMarkBackground = new createjs.Shape();
 	this.checkMarkBackground.name = "checkmarkbackground";
 	this.checkMarkBackground.graphics.beginFill("red").drawRoundRect(0, 0, 40, 40, 8);
-	
+	//this.checkMarkBackground.graphics.setStrokeStyle( 0 ).beginStroke( '#000' ).drawRect( 0, 0, this.width, this.height);
+	//var hit = new createjs.Shape();
+	//hit.graphics.beginFill("#000").drawRect(0, 0, this.width, this.height);
+	//this.checkMarkBackground.hitArea = hit;
+
 	this.checkMark = new createjs.Shape();
 	this.checkMark.name = "checkmark";
 	this.checkMark.graphics.beginFill("white").drawRoundRect(0, 0, 32, 32, 6);
@@ -56,10 +59,13 @@ org.apache.flex.createjs.staticControls.CheckBox.prototype.addToParent = functio
 	this.checkBoxLabel.textBaseline = "middle";
 	this.checkBoxLabel.x = 45;
 	this.checkBoxLabel.y = 40/2;
-	
+
 	this.element = new createjs.Container();
 	this.element.name = "checkbox";
 	this.element.addChild(this.checkMarkBackground, this.checkBoxLabel, this.checkMark);
+	// use bind(this) to avoid loose scope
+	this.element.onClick = this.clickHandler.bind(this);
+
 	p.addChild(this.element);
 
     this.positioner = this.element;
@@ -101,3 +107,11 @@ org.apache.flex.createjs.staticControls.CheckBox.prototype.set_selected = functi
 	this.checkMark.visible = this.selected = value;
 	this.element.getStage().update();
 };
+
+/**
+ * @expose
+ * @this {org.apache.flex.createjs.staticControls.CheckBox}
+ */
+org.apache.flex.createjs.staticControls.CheckBox.prototype.clickHandler = function(event) {
+	this.set_selected(!this.get_selected());
+};