MCPcopy Create free account
hub / github.com/defold/defold / LuaGetParent

Function LuaGetParent

engine/gui/src/gui_script.cpp:3750–3772  ·  view source on GitHub ↗

gets the parent of the specified node * Returns the parent node of the specified node. * If the supplied node does not have a parent, `nil` is returned. * * @name gui.get_parent * @param node [type:node] the node from which to retrieve its parent * @return parent [type:node|nil] parent instance or `nil` */

Source from the content-addressed store, hash-verified

3748 * @return parent [type:node|nil] parent instance or `nil`
3749 */
3750 int LuaGetParent(lua_State* L)
3751 {
3752 DM_LUA_STACK_CHECK(L, 1);
3753
3754 dmGui::HScene scene = dmGui::LuaCheckScene(L);
3755 dmGui::HNode node = dmGui::LuaCheckNode(L, 1);
3756 dmGui::HNode parent = dmGui::GetNodeParent(scene, node);
3757
3758 if (parent != dmGui::INVALID_HANDLE)
3759 {
3760 NodeProxy* node_proxy = (NodeProxy *)lua_newuserdata(L, sizeof(NodeProxy));
3761 node_proxy->m_Scene = scene;
3762 node_proxy->m_Node = parent;
3763 luaL_getmetatable(L, NODE_PROXY_TYPE_NAME);
3764 lua_setmetatable(L, -2);
3765 }
3766 else
3767 {
3768 lua_pushnil(L);
3769 }
3770
3771 return 1;
3772 }
3773
3774 /*# sets the parent of the node
3775 * Sets the parent node of the specified node.

Callers

nothing calls this directly

Calls 6

LuaCheckSceneFunction · 0.85
LuaCheckNodeFunction · 0.85
GetNodeParentFunction · 0.85
lua_newuserdataFunction · 0.85
lua_setmetatableFunction · 0.85
lua_pushnilFunction · 0.85

Tested by

no test coverage detected