mirror of https://github.com/axmolengine/axmol.git
Remove useless manual bindings for addEventListener functions in UI
This commit is contained in:
parent
23f27534f6
commit
be2a3077c2
|
@ -29,433 +29,6 @@
|
|||
using namespace cocos2d;
|
||||
using namespace cocos2d::ui;
|
||||
|
||||
class JSStudioEventListenerWrapper: public JSCallbackWrapper {
|
||||
public:
|
||||
virtual void eventCallbackFunc(Ref*,int);
|
||||
};
|
||||
|
||||
void JSStudioEventListenerWrapper::eventCallbackFunc(Ref* sender,int eventType)
|
||||
{
|
||||
JSContext *cx = ScriptingCore::getInstance()->getGlobalContext();
|
||||
JS::RootedObject thisObj(cx, getJSCallbackThis().toObjectOrNull());
|
||||
JS::RootedValue callback(cx, getJSCallbackFunc());
|
||||
js_proxy_t *proxy = js_get_or_create_proxy(cx, sender);
|
||||
JS::RootedValue retval(cx);
|
||||
if (!callback.isNullOrUndefined())
|
||||
{
|
||||
jsval touchVal = INT_TO_JSVAL(eventType);
|
||||
|
||||
jsval valArr[2];
|
||||
valArr[0] = OBJECT_TO_JSVAL(proxy->obj);
|
||||
valArr[1] = touchVal;
|
||||
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
JS_CallFunctionValue(cx, thisObj, callback, JS::HandleValueArray::fromMarkedLocation(2, valArr), &retval);
|
||||
}
|
||||
}
|
||||
|
||||
class CallbacksComponent: public cocos2d::Component {
|
||||
public:
|
||||
CallbacksComponent();
|
||||
virtual ~CallbacksComponent();
|
||||
|
||||
cocos2d::__Dictionary* callbacks;
|
||||
static const std::string NAME;
|
||||
};
|
||||
|
||||
const std::string CallbacksComponent::NAME = "JSB_Callbacks";
|
||||
|
||||
CallbacksComponent::CallbacksComponent()
|
||||
{
|
||||
setName(NAME);
|
||||
callbacks = cocos2d::__Dictionary::create();
|
||||
CC_SAFE_RETAIN(callbacks);
|
||||
}
|
||||
|
||||
CallbacksComponent::~CallbacksComponent()
|
||||
{
|
||||
CC_SAFE_RELEASE(callbacks);
|
||||
}
|
||||
|
||||
static bool js_cocos2dx_UIWidget_addTouchEventListener(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
ui::Widget* cobj = (ui::Widget *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object");
|
||||
|
||||
if (argc == 2) {
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper();
|
||||
tmpObj->autorelease();
|
||||
|
||||
CallbacksComponent *comp = static_cast<CallbacksComponent *>(cobj->getComponent(CallbacksComponent::NAME));
|
||||
if (nullptr == comp)
|
||||
{
|
||||
comp = new CallbacksComponent();
|
||||
comp->autorelease();
|
||||
cobj->addComponent(comp);
|
||||
}
|
||||
cocos2d::__Dictionary* dict = comp->callbacks;
|
||||
dict->setObject(tmpObj, "widgetTouchEvent");
|
||||
|
||||
tmpObj->setJSCallbackFunc(args.get(0));
|
||||
tmpObj->setJSCallbackThis(args.get(1));
|
||||
|
||||
cobj->addTouchEventListener(tmpObj, toucheventselector(JSStudioEventListenerWrapper::eventCallbackFunc));
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(argc == 1){
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(0)));
|
||||
cobj->addTouchEventListener([=](Ref* widget, Widget::TouchEventType type)->void{
|
||||
jsval arg[2];
|
||||
js_proxy_t *proxy = js_get_or_create_proxy(cx, widget);
|
||||
if(proxy)
|
||||
arg[0] = OBJECT_TO_JSVAL(proxy->obj);
|
||||
else
|
||||
arg[0] = JSVAL_NULL;
|
||||
arg[1] = int32_to_jsval(cx, (int32_t)type);
|
||||
JS::RootedValue rval(cx);
|
||||
|
||||
bool ok = func->invoke(2, arg, &rval);
|
||||
if (!ok && JS_IsExceptionPending(cx)) {
|
||||
JS_ReportPendingException(cx);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "Invalid number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool js_cocos2dx_UICheckBox_addEventListener(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
ui::CheckBox* cobj = (ui::CheckBox *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object");
|
||||
|
||||
if (argc == 2) {
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper();
|
||||
tmpObj->autorelease();
|
||||
|
||||
CallbacksComponent *comp = static_cast<CallbacksComponent *>(cobj->getComponent(CallbacksComponent::NAME));
|
||||
if (nullptr == comp)
|
||||
{
|
||||
comp = new CallbacksComponent();
|
||||
comp->autorelease();
|
||||
cobj->addComponent(comp);
|
||||
}
|
||||
cocos2d::__Dictionary* dict = comp->callbacks;
|
||||
dict->setObject(tmpObj, "checkBoxEventListener");
|
||||
|
||||
tmpObj->setJSCallbackFunc(args.get(0));
|
||||
tmpObj->setJSCallbackThis(args.get(1));
|
||||
|
||||
cobj->addEventListenerCheckBox(tmpObj, checkboxselectedeventselector(JSStudioEventListenerWrapper::eventCallbackFunc));
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(argc == 1){
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(0)));
|
||||
cobj->addEventListener([=](Ref* widget, CheckBox::EventType type)->void{
|
||||
jsval arg[2];
|
||||
js_proxy_t *proxy = js_get_or_create_proxy(cx, widget);
|
||||
if(proxy)
|
||||
arg[0] = OBJECT_TO_JSVAL(proxy->obj);
|
||||
else
|
||||
arg[0] = JSVAL_NULL;
|
||||
arg[1] = int32_to_jsval(cx, (int32_t)type);
|
||||
JS::RootedValue rval(cx);
|
||||
|
||||
bool ok = func->invoke(2, arg, &rval);
|
||||
if (!ok && JS_IsExceptionPending(cx)) {
|
||||
JS_ReportPendingException(cx);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "Invalid number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool js_cocos2dx_UISlider_addEventListener(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
ui::Slider* cobj = (ui::Slider *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object");
|
||||
|
||||
if (argc == 2) {
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper();
|
||||
tmpObj->autorelease();
|
||||
|
||||
CallbacksComponent *comp = static_cast<CallbacksComponent *>(cobj->getComponent(CallbacksComponent::NAME));
|
||||
if (nullptr == comp)
|
||||
{
|
||||
comp = new CallbacksComponent();
|
||||
comp->autorelease();
|
||||
cobj->addComponent(comp);
|
||||
}
|
||||
cocos2d::__Dictionary* dict = comp->callbacks;
|
||||
dict->setObject(tmpObj, "sliderEventListener");
|
||||
|
||||
tmpObj->setJSCallbackFunc(args.get(0));
|
||||
tmpObj->setJSCallbackThis(args.get(1));
|
||||
|
||||
cobj->addEventListenerSlider(tmpObj, sliderpercentchangedselector(JSStudioEventListenerWrapper::eventCallbackFunc));
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(argc == 1){
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(0)));
|
||||
cobj->addEventListener([=](Ref* widget, Slider::EventType type)->void{
|
||||
jsval arg[2];
|
||||
js_proxy_t *proxy = js_get_or_create_proxy(cx, widget);
|
||||
if(proxy)
|
||||
arg[0] = OBJECT_TO_JSVAL(proxy->obj);
|
||||
else
|
||||
arg[0] = JSVAL_NULL;
|
||||
arg[1] = int32_to_jsval(cx, (int32_t)type);
|
||||
JS::RootedValue rval(cx);
|
||||
|
||||
bool ok = func->invoke(2, arg, &rval);
|
||||
if (!ok && JS_IsExceptionPending(cx)) {
|
||||
JS_ReportPendingException(cx);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "Invalid number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool js_cocos2dx_UITextField_addEventListener(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
ui::TextField* cobj = (ui::TextField *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object");
|
||||
|
||||
if (argc == 2) {
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper();
|
||||
tmpObj->autorelease();
|
||||
|
||||
CallbacksComponent *comp = static_cast<CallbacksComponent *>(cobj->getComponent(CallbacksComponent::NAME));
|
||||
if (nullptr == comp)
|
||||
{
|
||||
comp = new CallbacksComponent();
|
||||
comp->autorelease();
|
||||
cobj->addComponent(comp);
|
||||
}
|
||||
cocos2d::__Dictionary* dict = comp->callbacks;
|
||||
dict->setObject(tmpObj, "textfieldEventListener");
|
||||
|
||||
tmpObj->setJSCallbackFunc(args.get(0));
|
||||
tmpObj->setJSCallbackThis(args.get(1));
|
||||
|
||||
cobj->addEventListenerTextField(tmpObj, textfieldeventselector(JSStudioEventListenerWrapper::eventCallbackFunc));
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(argc == 1){
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(0)));
|
||||
cobj->addEventListener([=](Ref* widget, TextField::EventType type)->void{
|
||||
jsval arg[2];
|
||||
js_proxy_t *proxy = js_get_or_create_proxy(cx, widget);
|
||||
if(proxy)
|
||||
arg[0] = OBJECT_TO_JSVAL(proxy->obj);
|
||||
else
|
||||
arg[0] = JSVAL_NULL;
|
||||
arg[1] = int32_to_jsval(cx, (int32_t)type);
|
||||
JS::RootedValue rval(cx);
|
||||
|
||||
bool ok = func->invoke(2, arg, &rval);
|
||||
if (!ok && JS_IsExceptionPending(cx)) {
|
||||
JS_ReportPendingException(cx);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "Invalid number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool js_cocos2dx_UIPageView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
ui::PageView* cobj = (ui::PageView *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object");
|
||||
|
||||
if (argc == 2) {
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper();
|
||||
tmpObj->autorelease();
|
||||
|
||||
CallbacksComponent *comp = static_cast<CallbacksComponent *>(cobj->getComponent(CallbacksComponent::NAME));
|
||||
if (nullptr == comp)
|
||||
{
|
||||
comp = new CallbacksComponent();
|
||||
comp->autorelease();
|
||||
cobj->addComponent(comp);
|
||||
}
|
||||
cocos2d::__Dictionary* dict = comp->callbacks;
|
||||
dict->setObject(tmpObj, "pageViewEventListener");
|
||||
|
||||
tmpObj->setJSCallbackFunc(args.get(0));
|
||||
tmpObj->setJSCallbackThis(args.get(1));
|
||||
|
||||
cobj->addEventListenerPageView(tmpObj, pagevieweventselector(JSStudioEventListenerWrapper::eventCallbackFunc));
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(argc == 1){
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(0)));
|
||||
cobj->addEventListener([=](Ref* widget, PageView::EventType type)->void{
|
||||
jsval arg[2];
|
||||
js_proxy_t *proxy = js_get_or_create_proxy(cx, widget);
|
||||
if(proxy)
|
||||
arg[0] = OBJECT_TO_JSVAL(proxy->obj);
|
||||
else
|
||||
arg[0] = JSVAL_NULL;
|
||||
arg[1] = int32_to_jsval(cx, (int32_t)type);
|
||||
JS::RootedValue rval(cx);
|
||||
|
||||
bool ok = func->invoke(2, arg, &rval);
|
||||
if (!ok && JS_IsExceptionPending(cx)) {
|
||||
JS_ReportPendingException(cx);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "Invalid number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool js_cocos2dx_UIScrollView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
ui::ScrollView* cobj = (ui::ScrollView *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object");
|
||||
|
||||
if (argc == 2) {
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper();
|
||||
tmpObj->autorelease();
|
||||
|
||||
CallbacksComponent *comp = static_cast<CallbacksComponent *>(cobj->getComponent(CallbacksComponent::NAME));
|
||||
if (nullptr == comp)
|
||||
{
|
||||
comp = new CallbacksComponent();
|
||||
comp->autorelease();
|
||||
cobj->addComponent(comp);
|
||||
}
|
||||
cocos2d::__Dictionary* dict = comp->callbacks;
|
||||
dict->setObject(tmpObj, "scrollViewEventListener");
|
||||
|
||||
tmpObj->setJSCallbackFunc(args.get(0));
|
||||
tmpObj->setJSCallbackThis(args.get(1));
|
||||
|
||||
cobj->addEventListenerScrollView(tmpObj, scrollvieweventselector(JSStudioEventListenerWrapper::eventCallbackFunc));
|
||||
|
||||
return true;
|
||||
}else if(argc == 1){
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(0)));
|
||||
cobj->addEventListener([=](Ref* widget, ScrollView::EventType type)->void{
|
||||
jsval arg[2];
|
||||
js_proxy_t *proxy = js_get_or_create_proxy(cx, widget);
|
||||
if(proxy)
|
||||
arg[0] = OBJECT_TO_JSVAL(proxy->obj);
|
||||
else
|
||||
arg[0] = JSVAL_NULL;
|
||||
arg[1] = int32_to_jsval(cx, (int32_t)type);
|
||||
JS::RootedValue rval(cx);
|
||||
|
||||
bool ok = func->invoke(2, arg, &rval);
|
||||
if (!ok && JS_IsExceptionPending(cx)) {
|
||||
JS_ReportPendingException(cx);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "Invalid number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool js_cocos2dx_UIListView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
ui::ListView* cobj = (ui::ListView *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object");
|
||||
|
||||
if (argc == 2) {
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper();
|
||||
tmpObj->autorelease();
|
||||
|
||||
CallbacksComponent *comp = static_cast<CallbacksComponent *>(cobj->getComponent(CallbacksComponent::NAME));
|
||||
if (nullptr == comp)
|
||||
{
|
||||
comp = new CallbacksComponent();
|
||||
comp->autorelease();
|
||||
cobj->addComponent(comp);
|
||||
}
|
||||
cocos2d::__Dictionary* dict = comp->callbacks;
|
||||
dict->setObject(tmpObj, "listViewEventListener");
|
||||
|
||||
tmpObj->setJSCallbackFunc(args.get(0));
|
||||
tmpObj->setJSCallbackThis(args.get(1));
|
||||
|
||||
cobj->addEventListenerListView(tmpObj, listvieweventselector(JSStudioEventListenerWrapper::eventCallbackFunc));
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(argc == 1){
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(0)));
|
||||
auto lambda = [=](Ref* widget, ListView::EventType type)->void{
|
||||
jsval arg[2];
|
||||
js_proxy_t *proxy = js_get_or_create_proxy(cx, widget);
|
||||
if(proxy)
|
||||
arg[0] = OBJECT_TO_JSVAL(proxy->obj);
|
||||
else
|
||||
arg[0] = JSVAL_NULL;
|
||||
arg[1] = int32_to_jsval(cx, (int32_t)type);
|
||||
JS::RootedValue rval(cx);
|
||||
|
||||
bool ok = func->invoke(2, arg, &rval);
|
||||
if (!ok && JS_IsExceptionPending(cx)) {
|
||||
JS_ReportPendingException(cx);
|
||||
}
|
||||
};
|
||||
cocos2d::ui::ListView::ccListViewCallback cb = lambda;
|
||||
cobj->addEventListener(cb);
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "Invalid number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool js_cocos2dx_LayoutParameter_setMargin(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
|
@ -639,35 +212,12 @@ static bool js_cocos2dx_CCEditBox_setDelegate(JSContext *cx, uint32_t argc, jsva
|
|||
return false;
|
||||
}
|
||||
|
||||
extern JSObject* jsb_cocos2d_ui_Widget_prototype;
|
||||
extern JSObject* jsb_cocos2d_ui_CheckBox_prototype;
|
||||
extern JSObject* jsb_cocos2d_ui_Slider_prototype;
|
||||
extern JSObject* jsb_cocos2d_ui_TextField_prototype;
|
||||
extern JSObject* jsb_cocos2d_ui_LayoutParameter_prototype;
|
||||
extern JSObject* jsb_cocos2d_ui_PageView_prototype;
|
||||
extern JSObject* jsb_cocos2d_ui_ScrollView_prototype;
|
||||
extern JSObject* jsb_cocos2d_ui_ListView_prototype;
|
||||
extern JSObject* jsb_cocos2d_ui_EditBox_prototype;
|
||||
|
||||
void register_all_cocos2dx_ui_manual(JSContext* cx, JS::HandleObject global)
|
||||
{
|
||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), "addTouchEventListener", js_cocos2dx_UIWidget_addTouchEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_CheckBox_prototype), "addEventListener", js_cocos2dx_UICheckBox_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_Slider_prototype), "addEventListener", js_cocos2dx_UISlider_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_TextField_prototype), "addEventListener", js_cocos2dx_UITextField_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_PageView_prototype), "addEventListener", js_cocos2dx_UIPageView_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_ScrollView_prototype), "addEventListener", js_cocos2dx_UIScrollView_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_ListView_prototype), "addEventListener", js_cocos2dx_UIListView_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_LayoutParameter_prototype), "setMargin", js_cocos2dx_LayoutParameter_setMargin, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_LayoutParameter_prototype), "getMargin", js_cocos2dx_LayoutParameter_getMargin, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_EditBox_prototype), "setDelegate", js_cocos2dx_CCEditBox_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
}
|
||||
|
|
|
@ -507,3 +507,33 @@ if (ccui.VideoPlayer)
|
|||
ccui.Widget.prototype.addNode = ccui.Widget.prototype.addChild;
|
||||
ccui.Widget.prototype.getSize = ccui.Widget.prototype.getContentSize;
|
||||
ccui.Widget.prototype.setSize = ccui.Widget.prototype.setContentSize;
|
||||
|
||||
/*
|
||||
* UIWidget's event listeners wrapper
|
||||
*/
|
||||
ccui.Widget.prototype._addTouchEventListener = ccui.Widget.prototype.addTouchEventListener;
|
||||
ccui.Widget.prototype.addTouchEventListener = function (selector, target) {
|
||||
if (target === undefined)
|
||||
this._addTouchEventListener(selector);
|
||||
else
|
||||
this._addTouchEventListener(selector.bind(target));
|
||||
};
|
||||
|
||||
function _ui_addEventListener(selector, target) {
|
||||
if (target === undefined)
|
||||
this._addTouchEventListener(selector);
|
||||
else
|
||||
this._addTouchEventListener(selector.bind(target));
|
||||
}
|
||||
function _ui_applyEventListener(ctor) {
|
||||
var proto = ctor.prototype;
|
||||
proto._addEventListener = proto.addEventListener;
|
||||
proto.addEventListener = _ui_addEventListener;
|
||||
}
|
||||
|
||||
_ui_applyEventListener(ccui.CheckBox);
|
||||
_ui_applyEventListener(ccui.Slider);
|
||||
_ui_applyEventListener(ccui.TextField);
|
||||
_ui_applyEventListener(ccui.PageView);
|
||||
_ui_applyEventListener(ccui.ScrollView);
|
||||
_ui_applyEventListener(ccui.ListView);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 2318a1593d2d490a3860179acaf81a1bf867a36b
|
||||
Subproject commit 4ecd2f4536bd57d42b4b370a6a4fc7c7420f5404
|
|
@ -41,7 +41,7 @@ classes_need_extend = Layout Widget Button CheckBox ImageView Text TextAtlas Tex
|
|||
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
|
||||
# functions from all classes.
|
||||
|
||||
skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener ccTouch.* addEventListener addTouchEventListener],
|
||||
skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener ccTouch.*],
|
||||
Widget::[(s|g)etUserObject],
|
||||
Layer::[getInputManager],
|
||||
LayoutParameter::[(s|g)etMargin],
|
||||
|
|
Loading…
Reference in New Issue