本文整理汇总了C++中IUIElement::GetVariableDesc方法的典型用法代码示例。如果您正苦于以下问题:C++ IUIElement::GetVariableDesc方法的具体用法?C++ IUIElement::GetVariableDesc怎么用?C++ IUIElement::GetVariableDesc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUIElement
的用法示例。
在下文中一共展示了IUIElement::GetVariableDesc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetVariable
//------------------------------------------------------------------------
int CScriptBind_UIAction::GetVariable( IFunctionHandler *pH, const char * elementName, int instanceID, const char* varName )
{
IUIElement* pElement = GetElement( elementName, instanceID );
if ( pElement )
{
const SUIParameterDesc* pVarDesc = pElement->GetVariableDesc( varName );
if ( pVarDesc )
{
TUIData value;
if ( pElement->GetVariable( pVarDesc, value ) )
{
bool ok;
ScriptAnyValue res = SUIToLuaConversationHelper::UIValueToLuaValue(value, ok);
if (!ok)
{
UIACTION_WARNING( "LUA: Error reading variable %s from UI Element %s", varName, elementName );
}
return pH->EndFunctionAny( res );
}
}
UIACTION_WARNING( "LUA: Element %s has no variable %s", elementName, varName );
}
else
{
UIACTION_WARNING( "LUA: UIElement %s does not exist", elementName );
}
return pH->EndFunction( false );
}
示例2: SetVariable
//------------------------------------------------------------------------
int CScriptBind_UIAction::SetVariable( IFunctionHandler *pH, const char * elementName, int instanceID, const char* varName )
{
if (pH->GetParamCount() != 4)
{
UIACTION_ERROR( "LUA: UIAction.SetVariable - wrong number of arguments!");
return pH->EndFunction(false);
}
IUIElement* pElement = GetElement( elementName, instanceID );
if ( pElement )
{
const SUIParameterDesc* pVarDesc = pElement->GetVariableDesc( varName );
if ( pVarDesc )
{
bool bRet = true;
TUIData value;
if (SUIToLuaConversationHelper::LuaArgToUIArg(pH, 4, value))
{
bool bVarOk = true;
if ( instanceID < 0 )
{
IUIElementIteratorPtr elements = pElement->GetInstances();
while ( IUIElement* pInstance = elements->Next() )
bVarOk &= pInstance->SetVariable( pVarDesc, value );
}
else
{
bVarOk = pElement->SetVariable( pVarDesc, value );
}
if ( bVarOk )
return pH->EndFunction(true);
else
{
UIACTION_WARNING( "LUA: Element %s has no variable %s", elementName, varName );
}
}
else
{
UIACTION_WARNING( "LUA: Element %s: wrong datatype for variable %s", elementName, varName );
}
}
else
{
UIACTION_WARNING( "LUA: Element %s has no variable %s", elementName, varName );
}
}
else
{
UIACTION_WARNING( "LUA: UIElement %s does not exist", elementName );
}
return pH->EndFunction(false);
}