Skip to content

Commit

Permalink
Merge pull request cocos2d#12958 from VisualSJ/v3.7.1-bindCallback
Browse files Browse the repository at this point in the history
[ci skip] Parse Touch/Click callback in JS Studio parser
  • Loading branch information
pandamicro committed Jul 23, 2015
2 parents 50fb53f + d490049 commit 5b8371a
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,23 @@
widget.setColor(getColor(color));

setLayoutComponent(widget, json);
bindCallback(widget, json);
};

var bindCallback = function(widget, json){
var callBackType = json["CallBackType"];
var callBackName = json["CallBackName"];
var callBack = function(e){
if(typeof widget[callBackName] === "function")
widget[callBackName](e);
};
if(callBackType === "Click"){
widget.addClickEventListener(callBack);
}else if(callBackType === "Touch"){
widget.addTouchEventListener(callBack);
}else if(callBackType === "Event"){
widget.addCCSEventListener(callBack);
}
};

var setLayoutComponent = function(widget, json){
Expand Down Expand Up @@ -401,6 +418,7 @@
layoutComponent.setPercentHeightEnabled(sizeYPercentEnable);
layoutComponent.setPercentWidth(sizeXPercent);
layoutComponent.setPercentHeight(sizeYPercent);
layoutComponent.setPercentWidthEnabled(sizeXPercentEnable || sizeYPercentEnable);
layoutComponent.setStretchWidthEnabled(stretchHorizontalEnabled);
layoutComponent.setStretchHeightEnabled(stretchVerticalEnabled);

Expand Down

0 comments on commit 5b8371a

Please sign in to comment.