2014-03-11 17:51:12 +08:00
|
|
|
/****************************************************************************
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-09 22:23:34 +08:00
|
|
|
https://axis-project.github.io/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
2022-07-12 21:31:54 +08:00
|
|
|
#include "scripting/lua-bindings/manual/ui/lua_axis_ui_manual.hpp"
|
|
|
|
#include "scripting/lua-bindings/auto/lua_axis_ui_auto.hpp"
|
2022-07-15 19:17:01 +08:00
|
|
|
#if (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID || AX_TARGET_PLATFORM == AX_PLATFORM_IOS) && !defined(AX_TARGET_OS_TVOS)
|
2022-07-12 21:31:54 +08:00
|
|
|
# include "scripting/lua-bindings/auto/lua_axis_video_auto.hpp"
|
|
|
|
# include "scripting/lua-bindings/manual/ui/lua_axis_video_manual.hpp"
|
|
|
|
# include "scripting/lua-bindings/auto/lua_axis_webview_auto.hpp"
|
|
|
|
# include "scripting/lua-bindings/manual/ui/lua_axis_webview_manual.hpp"
|
2022-07-15 19:17:01 +08:00
|
|
|
#elif AX_TARGET_PLATFORM == AX_PLATFORM_WIN32
|
2022-05-18 12:52:05 +08:00
|
|
|
# if defined(AX_ENABLE_MFMEDIA)
|
2022-07-12 21:31:54 +08:00
|
|
|
# include "scripting/lua-bindings/auto/lua_axis_video_auto.hpp"
|
|
|
|
# include "scripting/lua-bindings/manual/ui/lua_axis_video_manual.hpp"
|
2022-05-18 12:52:05 +08:00
|
|
|
# endif
|
|
|
|
# if defined(AX_ENABLE_MSEDGE_WEBVIEW2)
|
2022-07-12 21:31:54 +08:00
|
|
|
# include "scripting/lua-bindings/auto/lua_axis_webview_auto.hpp"
|
|
|
|
# include "scripting/lua-bindings/manual/ui/lua_axis_webview_manual.hpp"
|
2022-05-18 12:52:05 +08:00
|
|
|
# endif
|
2015-04-17 14:08:47 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "scripting/lua-bindings/manual/tolua_fix.h"
|
|
|
|
#include "scripting/lua-bindings/manual/LuaBasicConversions.h"
|
2022-07-12 21:31:54 +08:00
|
|
|
#include "scripting/lua-bindings/manual/base/LuaScriptHandlerMgr.h"
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "scripting/lua-bindings/manual/CCLuaValue.h"
|
2014-03-11 20:59:35 +08:00
|
|
|
#include "ui/CocosGUI.h"
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "scripting/lua-bindings/manual/CCLuaEngine.h"
|
2016-04-18 15:09:21 +08:00
|
|
|
#include "base/CCEventListenerFocus.h"
|
2014-03-11 17:51:12 +08:00
|
|
|
|
|
|
|
using namespace ui;
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
static int handleUIEvent(int handler, axis::Ref* sender, int eventType)
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
2014-06-12 10:10:37 +08:00
|
|
|
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
stack->pushObject(sender, "ax.Ref");
|
2014-06-12 10:10:37 +08:00
|
|
|
stack->pushInt(eventType);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-06-12 10:10:37 +08:00
|
|
|
stack->executeFunctionByHandler(handler, 2);
|
|
|
|
stack->clean();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-06-12 10:10:37 +08:00
|
|
|
return 0;
|
2014-03-11 17:51:12 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Widget_addTouchEventListener(lua_State* L)
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2014-03-11 17:51:12 +08:00
|
|
|
Widget* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "axui.Widget", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
self = static_cast<Widget*>(tolua_tousertype(L, 1, 0));
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_Widget_addTouchEventListener'\n", NULL);
|
2016-01-27 20:21:32 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err))
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(L, 2, 0));
|
|
|
|
|
|
|
|
self->addTouchEventListener(
|
2022-07-11 17:50:21 +08:00
|
|
|
[=](axis::Ref* ref, Widget::TouchEventType eventType) { handleUIEvent(handler, ref, (int)eventType); });
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-10-20 11:20:53 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
luaL_error(L, "'addTouchEventListener' function of Widget has wrong number of arguments: %d, was expecting %d\n",
|
|
|
|
argc, 1);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'addTouchEventListener'.", &tolua_err);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Widget_addClickEventListener(lua_State* L)
|
2015-01-22 10:21:38 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2015-01-22 10:21:38 +08:00
|
|
|
Widget* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-01-22 10:21:38 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "axui.Widget", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2015-01-22 10:21:38 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
self = static_cast<Widget*>(tolua_tousertype(L, 1, 0));
|
|
|
|
|
2015-01-22 10:21:38 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_Widget_addClickEventListener'\n", NULL);
|
2015-01-22 10:21:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-01-22 10:21:38 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-01-22 10:21:38 +08:00
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err))
|
2015-01-22 10:21:38 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(L, 2, 0));
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self->addClickEventListener([=](axis::Ref* sender) {
|
2015-01-22 10:21:38 +08:00
|
|
|
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
|
2022-07-12 21:31:54 +08:00
|
|
|
stack->pushObject(sender, "ax.Ref");
|
2015-01-22 10:21:38 +08:00
|
|
|
stack->executeFunctionByHandler(handler, 1);
|
|
|
|
stack->clean();
|
|
|
|
});
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-01-22 10:21:38 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
|
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
luaL_error(L, "'addClickEventListener' function of Widget has wrong number of arguments: %d, was expecting %d\n",
|
|
|
|
argc, 1);
|
2015-01-22 10:21:38 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-01-22 10:21:38 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'addClickEventListener'.", &tolua_err);
|
2015-01-22 10:21:38 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
static void extendWidget(lua_State* L)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "axui.Widget");
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(L, "addTouchEventListener", lua_axis_Widget_addTouchEventListener);
|
|
|
|
tolua_function(L, "addClickEventListener", lua_axis_Widget_addClickEventListener);
|
2014-03-11 17:51:12 +08:00
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_CheckBox_addEventListener(lua_State* L)
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2014-03-11 17:51:12 +08:00
|
|
|
CheckBox* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "axui.CheckBox", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
self = static_cast<CheckBox*>(tolua_tousertype(L, 1, 0));
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_CheckBox_addEventListener'\n", NULL);
|
2016-01-27 20:21:32 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err))
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(L, 2, 0));
|
|
|
|
|
|
|
|
self->addEventListener(
|
2022-07-11 17:50:21 +08:00
|
|
|
[=](axis::Ref* ref, CheckBox::EventType eventType) { handleUIEvent(handler, ref, (int)eventType); });
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-10-20 11:20:53 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
luaL_error(L, "'addEventListener' function of CheckBox has wrong number of arguments: %d, was expecting %d\n", argc,
|
|
|
|
1);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'addEventListener'.", &tolua_err);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendCheckBox(lua_State* L)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "axui.CheckBox");
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(L, "addEventListener", lua_axis_CheckBox_addEventListener);
|
2014-03-11 17:51:12 +08:00
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_RadioButton_addEventListener(lua_State* L)
|
2015-08-20 22:49:42 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2015-08-20 22:49:42 +08:00
|
|
|
RadioButton* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "axui.RadioButton", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2015-08-20 22:49:42 +08:00
|
|
|
#endif
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = static_cast<RadioButton*>(tolua_tousertype(L, 1, 0));
|
2015-08-20 22:49:42 +08:00
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_RadioButton_addEventListener'\n", NULL);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2015-08-20 22:49:42 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err))
|
2015-08-20 22:49:42 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(L, 2, 0));
|
2015-08-20 22:49:42 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self->addEventListener([=](RadioButton* radioButton, RadioButton::EventType eventType) {
|
2015-08-20 22:49:42 +08:00
|
|
|
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
|
2022-07-12 21:31:54 +08:00
|
|
|
stack->pushObject(radioButton, "axui.RadioButton");
|
2015-08-20 22:49:42 +08:00
|
|
|
stack->pushInt((int)eventType);
|
|
|
|
|
|
|
|
stack->executeFunctionByHandler(handler, 2);
|
|
|
|
stack->clean();
|
|
|
|
});
|
|
|
|
|
|
|
|
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(L, "'addEventListener' function of CheckBox has wrong number of arguments: %d, was expecting %d\n", argc,
|
|
|
|
1);
|
2015-08-20 22:49:42 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'addEventListener'.", &tolua_err);
|
2015-08-20 22:49:42 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendRadioButton(lua_State* L)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "axui.RadioButton");
|
2015-08-20 22:49:42 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2015-08-20 22:49:42 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(L, "addEventListener", lua_axis_RadioButton_addEventListener);
|
2015-08-20 22:49:42 +08:00
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_RadioButtonGroup_addEventListener(lua_State* L)
|
2015-08-20 22:49:42 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2015-08-20 22:49:42 +08:00
|
|
|
RadioButtonGroup* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "axui.RadioButtonGroup", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2015-08-20 22:49:42 +08:00
|
|
|
#endif
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = static_cast<RadioButtonGroup*>(tolua_tousertype(L, 1, 0));
|
2015-08-20 22:49:42 +08:00
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_RadioButtonGroup_addEventListener'\n", NULL);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2015-08-20 22:49:42 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err))
|
2015-08-20 22:49:42 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(L, 2, 0));
|
2015-08-20 22:49:42 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self->addEventListener([=](RadioButton* radioButton, int index, RadioButtonGroup::EventType eventType) {
|
2015-08-20 22:49:42 +08:00
|
|
|
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
stack->pushObject(radioButton, "axui.RadioButton");
|
2015-08-20 22:49:42 +08:00
|
|
|
stack->pushInt(index);
|
|
|
|
stack->pushInt((int)eventType);
|
|
|
|
|
|
|
|
stack->executeFunctionByHandler(handler, 3);
|
|
|
|
stack->clean();
|
|
|
|
});
|
|
|
|
|
|
|
|
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(L,
|
|
|
|
"'addEventListener' function of RadioButtonGroup has wrong number of arguments: %d, was expecting %d\n",
|
|
|
|
argc, 1);
|
2015-08-20 22:49:42 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'addEventListener'.", &tolua_err);
|
2015-08-20 22:49:42 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendRadioButtonGroup(lua_State* L)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "axui.RadioButtonGroup");
|
2015-08-20 22:49:42 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2015-08-20 22:49:42 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(L, "addEventListener", lua_axis_RadioButtonGroup_addEventListener);
|
2015-08-20 22:49:42 +08:00
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Slider_addEventListener(lua_State* L)
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2014-03-11 17:51:12 +08:00
|
|
|
Slider* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "axui.Slider", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
self = static_cast<Slider*>(tolua_tousertype(L, 1, 0));
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_Slider_addEventListener'\n", NULL);
|
2016-01-27 20:21:32 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err))
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(L, 2, 0));
|
|
|
|
|
|
|
|
self->addEventListener(
|
2022-07-11 17:50:21 +08:00
|
|
|
[=](axis::Ref* ref, Slider::EventType eventType) { handleUIEvent(handler, ref, (int)eventType); });
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-10-20 11:20:53 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
luaL_error(L, "'addEventListener' function of Slider has wrong number of arguments: %d, was expecting %d\n", argc,
|
|
|
|
1);
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'addEventListener'.", &tolua_err);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendSlider(lua_State* L)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "axui.Slider");
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(L, "addEventListener", lua_axis_Slider_addEventListener);
|
2014-03-11 17:51:12 +08:00
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_TextField_addEventListener(lua_State* L)
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2014-03-11 17:51:12 +08:00
|
|
|
TextField* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "axui.TextField", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
self = static_cast<TextField*>(tolua_tousertype(L, 1, 0));
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_TextField_addEventListener'\n", NULL);
|
2016-01-27 20:21:32 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err))
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(L, 2, 0));
|
|
|
|
|
|
|
|
self->addEventListener(
|
2022-07-11 17:50:21 +08:00
|
|
|
[=](axis::Ref* ref, TextField::EventType eventType) { handleUIEvent(handler, ref, (int)eventType); });
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-10-20 11:20:53 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
luaL_error(L, "'addEventListener' function of TextField has wrong number of arguments: %d, was expecting %d\n",
|
|
|
|
argc, 1);
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'addEventListener'.", &tolua_err);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendTextField(lua_State* L)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "axui.TextField");
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(L, "addEventListener", lua_axis_TextField_addEventListener);
|
2014-03-11 17:51:12 +08:00
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_PageView_addEventListener(lua_State* L)
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2014-03-11 17:51:12 +08:00
|
|
|
PageView* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "axui.PageView", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
self = static_cast<PageView*>(tolua_tousertype(L, 1, 0));
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_PageView_addEventListener'\n", NULL);
|
2016-01-27 20:21:32 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err))
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(L, 2, 0));
|
2022-07-11 17:50:21 +08:00
|
|
|
auto pageViewHandler = [=](axis::Ref* ref, PageView::EventType eventType) {
|
2014-06-12 10:10:37 +08:00
|
|
|
handleUIEvent(handler, ref, (int)eventType);
|
2016-01-27 20:21:32 +08:00
|
|
|
};
|
|
|
|
self->addEventListener((PageView::ccPageViewCallback)pageViewHandler);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-10-20 11:20:53 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
luaL_error(L, "'addEventListener' function of PageView has wrong number of arguments: %d, was expecting %d\n", argc,
|
|
|
|
1);
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'addEventListener'.", &tolua_err);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendPageView(lua_State* L)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "axui.PageView");
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(L, "addEventListener", lua_axis_PageView_addEventListener);
|
2014-03-11 17:51:12 +08:00
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_ScrollView_addEventListener(lua_State* L)
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2014-03-11 17:51:12 +08:00
|
|
|
ScrollView* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "axui.ScrollView", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
self = static_cast<ScrollView*>(tolua_tousertype(L, 1, 0));
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_ScrollView_addEventListener'\n", NULL);
|
2016-01-27 20:21:32 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err))
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(L, 2, 0));
|
|
|
|
|
|
|
|
self->addEventListener(
|
2022-07-11 17:50:21 +08:00
|
|
|
[=](axis::Ref* ref, ScrollView::EventType eventType) { handleUIEvent(handler, ref, (int)eventType); });
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-10-20 11:20:53 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
luaL_error(L, "'addEventListener' function of ScrollView has wrong number of arguments: %d, was expecting %d\n",
|
|
|
|
argc, 1);
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'addEventListener'.", &tolua_err);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendScrollView(lua_State* L)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "axui.ScrollView");
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(L, "addEventListener", lua_axis_ScrollView_addEventListener);
|
2014-03-11 17:51:12 +08:00
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_ListView_addEventListener(lua_State* L)
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2014-03-11 17:51:12 +08:00
|
|
|
ListView* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "axui.ListView", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
self = static_cast<ListView*>(tolua_tousertype(L, 1, 0));
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_ListView_addEventListener'\n", NULL);
|
2016-01-27 20:21:32 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err))
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(L, 2, 0));
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
auto listViewCallback = [=](axis::Ref* ref, ListView::EventType eventType) {
|
2014-06-12 10:10:37 +08:00
|
|
|
handleUIEvent(handler, ref, (int)eventType);
|
2014-06-23 17:04:59 +08:00
|
|
|
};
|
|
|
|
self->addEventListener((ui::ListView::ccListViewCallback)listViewCallback);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-10-20 11:20:53 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
luaL_error(L, "'addEventListener' function of ListView has wrong number of arguments: %d, was expecting %d\n", argc,
|
|
|
|
1);
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'addEventListener'.", &tolua_err);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_ListView_addScrollViewEventListener(lua_State* L)
|
2014-06-23 17:29:56 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2014-06-23 17:29:56 +08:00
|
|
|
ListView* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-06-23 17:29:56 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "axui.ListView", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-06-23 17:29:56 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
self = static_cast<ListView*>(tolua_tousertype(L, 1, 0));
|
|
|
|
|
2014-06-23 17:29:56 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_ListView_addScrollViewEventListener'\n", NULL);
|
2016-01-27 20:21:32 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-06-23 17:29:56 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err))
|
2014-06-23 17:29:56 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(L, 2, 0));
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
auto scrollViewCallback = [=](axis::Ref* ref, ui::ScrollView::EventType eventType) {
|
2014-06-23 17:42:04 +08:00
|
|
|
handleUIEvent(handler, ref, (int)eventType);
|
|
|
|
};
|
|
|
|
self->addEventListener((ui::ScrollView::ccScrollViewCallback)scrollViewCallback);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-10-20 11:20:53 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
|
2014-06-23 17:29:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
luaL_error(
|
|
|
|
L, "'addScrollViewEventListener' function of ListView has wrong number of arguments: %d, was expecting %d\n",
|
|
|
|
argc, 1);
|
|
|
|
|
2014-06-23 17:29:56 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-06-23 17:29:56 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'addScrollViewEventListener'.", &tolua_err);
|
2014-06-23 17:29:56 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
static void extendListView(lua_State* L)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "axui.ListView");
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(L, "addEventListener", lua_axis_ListView_addEventListener);
|
|
|
|
tolua_function(L, "addScrollViewEventListener", lua_axis_ListView_addScrollViewEventListener);
|
2014-03-11 17:51:12 +08:00
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_LayoutParameter_setMargin(lua_State* L)
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2014-03-11 17:51:12 +08:00
|
|
|
LayoutParameter* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "axui.LayoutParameter", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
self = static_cast<LayoutParameter*>(tolua_tousertype(L, 1, 0));
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_LayoutParameter_setMargin'\n", NULL);
|
2016-01-27 20:21:32 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(L) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!tolua_istable(L, 2, 0, &tolua_err))
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
Margin margin;
|
|
|
|
lua_pushstring(L, "left");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_gettable(L, 2);
|
|
|
|
margin.left = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1);
|
|
|
|
lua_pop(L, 1);
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_pushstring(L, "top");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_gettable(L, 2);
|
|
|
|
margin.top = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1);
|
|
|
|
lua_pop(L, 1);
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_pushstring(L, "right");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_gettable(L, 2);
|
|
|
|
margin.right = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1);
|
|
|
|
lua_pop(L, 1);
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_pushstring(L, "bottom");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_gettable(L, 2);
|
|
|
|
margin.bottom = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1);
|
|
|
|
lua_pop(L, 1);
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
self->setMargin(margin);
|
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
luaL_error(L, "'setMargin' function of LayoutParameter has wrong number of arguments: %d, was expecting %d\n", argc,
|
|
|
|
1);
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'setMargin'.", &tolua_err);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_LayoutParameter_getMargin(lua_State* L)
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2014-03-11 17:51:12 +08:00
|
|
|
LayoutParameter* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "axui.LayoutParameter", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
self = static_cast<LayoutParameter*>(tolua_tousertype(L, 1, 0));
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_LayoutParameter_getMargin'\n", NULL);
|
2016-01-27 20:21:32 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-03-11 17:51:12 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(L) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
if (0 == argc)
|
|
|
|
{
|
|
|
|
Margin margin = self->getMargin();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_newtable(L);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
lua_pushstring(L, "left");
|
|
|
|
lua_pushnumber(L, (lua_Number)margin.left);
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_rawset(L, -3);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
lua_pushstring(L, "top");
|
|
|
|
lua_pushnumber(L, (lua_Number)margin.top);
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_rawset(L, -3);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_pushstring(L, "right");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushnumber(L, (lua_Number)margin.right);
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_rawset(L, -3);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_pushstring(L, "bottom");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushnumber(L, (lua_Number)margin.bottom);
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_rawset(L, -3);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
luaL_error(L, "'getMargin' function of LayoutParameter has wrong number of arguments: %d, was expecting %d\n", argc,
|
|
|
|
0);
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'getMargin'.", &tolua_err);
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendLayoutParameter(lua_State* L)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "axui.LayoutParameter");
|
2014-03-11 17:51:12 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(L, "setMargin", lua_axis_LayoutParameter_setMargin);
|
|
|
|
tolua_function(L, "getMargin", lua_axis_LayoutParameter_getMargin);
|
2014-03-11 17:51:12 +08:00
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
static int tolua_cocos2d_EditBox_registerScriptEditBoxHandler(lua_State* L)
|
2014-09-12 17:07:06 +08:00
|
|
|
{
|
2014-11-26 21:54:18 +08:00
|
|
|
if (NULL == L)
|
2014-09-12 17:07:06 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2014-09-12 17:07:06 +08:00
|
|
|
EditBox* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-09-12 17:07:06 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "axui.EditBox", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-09-12 17:07:06 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
self = static_cast<EditBox*>(tolua_tousertype(L, 1, 0));
|
|
|
|
|
2014-09-12 17:07:06 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(L, "invalid 'self' in function 'tolua_cocos2d_EditBox_registerScriptEditBoxHandler'\n", NULL);
|
2016-01-27 20:21:32 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-09-12 17:07:06 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-09-12 17:07:06 +08:00
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err))
|
2014-09-12 17:07:06 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(L, 2, 0));
|
2014-09-12 17:07:06 +08:00
|
|
|
self->registerScriptEditBoxHandler(handler);
|
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
luaL_error(L, "%s function of EditBox has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"axui.EditBox:registerScriptEditBoxHandler", argc, 1);
|
2014-09-12 17:07:06 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-09-12 17:07:06 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'tolua_cocos2d_EditBox_registerScriptEditBoxHandler'.", &tolua_err);
|
2014-09-12 17:07:06 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
static int tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler(lua_State* L)
|
2014-09-12 17:07:06 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
if (NULL == L)
|
2014-09-12 17:07:06 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2014-09-12 17:07:06 +08:00
|
|
|
EditBox* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-09-12 17:07:06 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "axui.EditBox", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-09-12 17:07:06 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
self = static_cast<EditBox*>(tolua_tousertype(L, 1, 0));
|
|
|
|
|
2014-09-12 17:07:06 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(L, "invalid 'self' in function 'tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler'\n", NULL);
|
2016-01-27 20:21:32 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-09-12 17:07:06 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-09-12 17:07:06 +08:00
|
|
|
if (0 == argc)
|
|
|
|
{
|
|
|
|
self->unregisterScriptEditBoxHandler();
|
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
luaL_error(L, "%s function of EditBox has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"axui.EditBox:unregisterScriptEditBoxHandler", argc, 0);
|
2014-09-12 17:07:06 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-09-12 17:07:06 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler'.", &tolua_err);
|
2014-09-12 17:07:06 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
static void extendEditBox(lua_State* L)
|
2014-09-12 17:07:06 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "axui.EditBox");
|
2014-11-26 21:54:18 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2014-09-12 17:07:06 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(L, "registerScriptEditBoxHandler");
|
|
|
|
lua_pushcfunction(L, tolua_cocos2d_EditBox_registerScriptEditBoxHandler);
|
|
|
|
lua_rawset(L, -3);
|
|
|
|
lua_pushstring(L, "unregisterScriptEditBoxHandler");
|
|
|
|
lua_pushcfunction(L, tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler);
|
|
|
|
lua_rawset(L, -3);
|
2014-09-12 17:07:06 +08:00
|
|
|
}
|
2014-11-26 21:54:18 +08:00
|
|
|
lua_pop(L, 1);
|
2014-09-12 17:07:06 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int register_all_axis_ui_manual(lua_State* L)
|
2014-03-11 17:51:12 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
|
|
|
extendWidget(L);
|
|
|
|
extendCheckBox(L);
|
2015-08-20 22:49:42 +08:00
|
|
|
extendRadioButton(L);
|
|
|
|
extendRadioButtonGroup(L);
|
2014-03-11 17:51:12 +08:00
|
|
|
extendSlider(L);
|
|
|
|
extendTextField(L);
|
|
|
|
extendPageView(L);
|
|
|
|
extendScrollView(L);
|
|
|
|
extendListView(L);
|
|
|
|
extendLayoutParameter(L);
|
2014-09-12 17:07:06 +08:00
|
|
|
extendEditBox(L);
|
|
|
|
|
2014-03-11 17:51:12 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-07-31 15:20:23 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_EventListenerFocus_create(lua_State* L)
|
2014-11-26 21:54:18 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
int argc = 0;
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(L, 1, "ax.EventListenerFocus", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-11-26 21:54:18 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListenerFocus* tolua_ret = axis::EventListenerFocus::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == tolua_ret)
|
2014-11-26 21:54:18 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-11-26 21:54:18 +08:00
|
|
|
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(L, ID, luaID, (void*)tolua_ret, "ax.EventListenerFocus");
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.EventListenerFocus:create", argc, 1);
|
2014-11-26 21:54:18 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "#ferror in function 'tolua_axis_EventListenerFocus_create'.", &tolua_err);
|
2014-11-26 21:54:18 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static void cloneFocusHandler(const EventListenerFocus* src, EventListenerFocus* dst)
|
2014-11-26 21:54:18 +08:00
|
|
|
{
|
|
|
|
if (nullptr == src || nullptr == dst)
|
|
|
|
return;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
LUA_FUNCTION handler =
|
|
|
|
ScriptHandlerMgr::getInstance()->getObjectHandler((void*)src, ScriptHandlerMgr::HandlerType::EVENT_FOCUS);
|
2014-11-26 21:54:18 +08:00
|
|
|
if (0 != handler)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int newscriptHandler =
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::ScriptEngineManager::getInstance()->getScriptEngine()->reallocateScriptHandler(handler);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)dst, newscriptHandler,
|
|
|
|
ScriptHandlerMgr::HandlerType::EVENT_FOCUS);
|
|
|
|
dst->onFocusChanged = [=](ui::Widget* widgetLostFocus, ui::Widget* widgetGetFocus) {
|
|
|
|
auto stack = LuaEngine::getInstance()->getLuaStack();
|
2021-11-15 19:05:08 +08:00
|
|
|
lua_State* L = stack->getLuaState();
|
2021-12-25 10:04:45 +08:00
|
|
|
int id = (widgetLostFocus) ? (int)widgetLostFocus->_ID : -1;
|
|
|
|
int* luaID = (widgetLostFocus) ? &widgetLostFocus->_luaID : nullptr;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(L, id, luaID, (void*)widgetLostFocus, "axui.Widget");
|
2021-12-25 10:04:45 +08:00
|
|
|
id = (widgetGetFocus) ? (int)widgetGetFocus->_ID : -1;
|
2014-11-26 21:54:18 +08:00
|
|
|
luaID = (widgetGetFocus) ? &widgetGetFocus->_luaID : nullptr;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(L, id, luaID, (void*)widgetGetFocus, "axui.Widget");
|
2021-11-15 19:05:08 +08:00
|
|
|
stack->executeFunctionByHandler(handler, 2);
|
2014-11-26 21:54:18 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_EventListenerFocus_clone(lua_State* L)
|
2014-11-26 21:54:18 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2014-11-26 21:54:18 +08:00
|
|
|
EventListenerFocus* self = nullptr;
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.EventListenerFocus", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-11-26 21:54:18 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
self = static_cast<EventListenerFocus*>(tolua_tousertype(L, 1, 0));
|
2014-11-26 21:54:18 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'tolua_axis_EventListenerFocus_clone'\n", nullptr);
|
2016-01-27 20:21:32 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-11-26 21:54:18 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListenerFocus* tolua_ret = axis::EventListenerFocus::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == tolua_ret)
|
2014-11-26 21:54:18 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
cloneFocusHandler(self, tolua_ret);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-11-26 21:54:18 +08:00
|
|
|
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(L, ID, luaID, (void*)tolua_ret, "ax.EventListenerFocus");
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.EventListenerFocus:clone", argc, 0);
|
2014-11-26 21:54:18 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "#ferror in function 'tolua_axis_EventListenerFocus_clone'.", &tolua_err);
|
2014-11-26 21:54:18 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_EventListenerFocus_registerScriptHandler(lua_State* L)
|
2014-11-26 21:54:18 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2014-11-26 21:54:18 +08:00
|
|
|
EventListenerFocus* self = nullptr;
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.EventListenerFocus", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-11-26 21:54:18 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
self = static_cast<EventListenerFocus*>(tolua_tousertype(L, 1, 0));
|
2014-11-26 21:54:18 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'tolua_axis_EventListenerFocus_registerScriptHandler'\n",
|
2021-12-25 10:04:45 +08:00
|
|
|
nullptr);
|
2016-01-27 20:21:32 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-11-26 21:54:18 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(L) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err))
|
2014-11-26 21:54:18 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(L, 2, 0);
|
|
|
|
|
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler,
|
|
|
|
ScriptHandlerMgr::HandlerType::EVENT_FOCUS);
|
|
|
|
|
|
|
|
self->onFocusChanged = [=](ui::Widget* widgetLostFocus, ui::Widget* widgetGetFocus) {
|
2021-11-15 19:05:08 +08:00
|
|
|
auto stack = LuaEngine::getInstance()->getLuaStack();
|
|
|
|
auto Ls = stack->getLuaState();
|
2021-12-25 10:04:45 +08:00
|
|
|
int id = (widgetLostFocus) ? (int)widgetLostFocus->_ID : -1;
|
2014-11-26 21:54:18 +08:00
|
|
|
int* luaID = (widgetLostFocus) ? &widgetLostFocus->_luaID : nullptr;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(Ls, id, luaID, (void*)widgetLostFocus, "axui.Widget");
|
2021-12-25 10:04:45 +08:00
|
|
|
id = (widgetGetFocus) ? (int)widgetGetFocus->_ID : -1;
|
2014-11-26 21:54:18 +08:00
|
|
|
luaID = (widgetGetFocus) ? &widgetGetFocus->_luaID : nullptr;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(Ls, id, luaID, (void*)widgetGetFocus, "axui.Widget");
|
2021-11-15 19:05:08 +08:00
|
|
|
stack->executeFunctionByHandler(handler, 2);
|
2014-11-26 21:54:18 +08:00
|
|
|
};
|
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.EventListenerFocus:registerScriptHandler", argc, 1);
|
2014-11-26 21:54:18 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "#ferror in function 'tolua_axis_EventListenerFocus_registerScriptHandler'.", &tolua_err);
|
2014-11-26 21:54:18 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendEventListenerFocusEvent(lua_State* L)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "ax.EventListenerFocus");
|
2014-11-26 21:54:18 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2014-11-26 21:54:18 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(L, "create", tolua_axis_EventListenerFocus_create);
|
|
|
|
tolua_function(L, "registerScriptHandler", tolua_axis_EventListenerFocus_registerScriptHandler);
|
|
|
|
tolua_function(L, "clone", tolua_axis_EventListenerFocus_clone);
|
2014-11-26 21:54:18 +08:00
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
2017-02-04 10:35:56 +08:00
|
|
|
int register_ui_module(lua_State* L)
|
2014-07-31 15:20:23 +08:00
|
|
|
{
|
2014-08-04 17:11:57 +08:00
|
|
|
lua_getglobal(L, "_G");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1)) // stack:...,_G,
|
2014-08-04 17:11:57 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
register_all_axis_ui(L);
|
|
|
|
register_all_axis_ui_manual(L);
|
2022-07-15 19:17:01 +08:00
|
|
|
#if (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID || AX_TARGET_PLATFORM == AX_PLATFORM_IOS) && !defined(AX_TARGET_OS_TVOS)
|
2022-07-12 21:31:54 +08:00
|
|
|
register_all_axis_video(L);
|
|
|
|
register_all_axis_video_manual(L);
|
|
|
|
register_all_axis_webview(L);
|
|
|
|
register_all_axis_webview_manual(L);
|
2022-07-15 19:17:01 +08:00
|
|
|
#elif AX_TARGET_PLATFORM == AX_PLATFORM_WIN32
|
2022-05-18 12:52:05 +08:00
|
|
|
# if defined(AX_ENABLE_MFMEDIA)
|
2022-07-12 21:31:54 +08:00
|
|
|
register_all_axis_video(L);
|
|
|
|
register_all_axis_video_manual(L);
|
2022-05-18 12:52:05 +08:00
|
|
|
# endif
|
|
|
|
# if defined(AX_ENABLE_MSEDGE_WEBVIEW2)
|
2022-07-12 21:31:54 +08:00
|
|
|
register_all_axis_webview(L);
|
|
|
|
register_all_axis_webview_manual(L);
|
2022-05-18 12:52:05 +08:00
|
|
|
# endif
|
2015-04-17 14:08:47 +08:00
|
|
|
#endif
|
2014-11-26 21:54:18 +08:00
|
|
|
extendEventListenerFocusEvent(L);
|
2014-08-04 17:11:57 +08:00
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-07-31 15:20:23 +08:00
|
|
|
return 1;
|
|
|
|
}
|