本文整理汇总了C++中JObject::RemoveChild方法的典型用法代码示例。如果您正苦于以下问题:C++ JObject::RemoveChild方法的具体用法?C++ JObject::RemoveChild怎么用?C++ JObject::RemoveChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JObject
的用法示例。
在下文中一共展示了JObject::RemoveChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FnSetParent
int JLuaServer::FnSetParent( lua_State* pLua )
{
if (lua_gettop( pLua ) != 2)
{
rlog.err( "LUA: Incorrect command usage: <setparent>. "
"Function takes 2 arguments, but %d is provided", lua_gettop( pLua ) );
lua_settop( pLua, 0 );
lua_pushnil( pLua );
return 1;
}
JObject* pParent = reinterpret_cast<JObject*>( lua_touserdata( pLua, 2 ) );
JObject* pObj = reinterpret_cast<JObject*>( lua_touserdata( pLua, 1 ) );
if (!pObj)
{
lua_pushnil( pLua );
return 0;
}
// set new parent for the object
JObject* pOldParent = pObj->GetParent();
if (pParent)
{
pParent->AddChild( pObj );
}
if (pOldParent)
{
pOldParent->RemoveChild( pObj );
}
pObj->SetParent( pParent );
return 0;
} // JLuaServer::FnSetParent
示例2: DeleteNode
bool JObjectTree::DeleteNode()
{
if (!m_pSelected) return false;
JObject* pParent = m_pSelected->GetParent();
if (!pParent) return false;
int idx = pParent->GetChildIndex( m_pSelected );
pParent->RemoveChild( m_pSelected );
if (idx >= pParent->GetNChildren()) idx = pParent->GetNChildren() - 1;
if (idx < 0) idx = 0;
m_pSelected = pParent->GetChild( idx );
if (!m_pSelected) m_pSelected = pParent;
m_pExpanded = m_pSelected;
return true;
} // JObjectTree::DeleteNode