本文整理汇总了C++中rocket::core::Element::GetOwnerDocument方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::GetOwnerDocument方法的具体用法?C++ Element::GetOwnerDocument怎么用?C++ Element::GetOwnerDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rocket::core::Element
的用法示例。
在下文中一共展示了Element::GetOwnerDocument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessEvent
virtual void ProcessEvent( Event &event )
{
if( !target ) {
return;
}
if( released ) {
// the function pointer has been released, but
// we're hanging around, waiting for shutdown or GC
return;
}
Element *elem = event.GetTargetElement();
if( elem->GetOwnerDocument() != target->GetOwnerDocument() ) {
// make sure the event originated from the same document as the original target
return;
}
UI_ScriptDocument *document = dynamic_cast<UI_ScriptDocument *>(elem->GetOwnerDocument());
if( !document || document->IsLoading() ) {
return;
}
fetchFunctionPtr( document->GetModule() );
// push elem and event as parameters to the internal function
// and call it
if( UI_Main::Get()->debugOn() ) {
Com_Printf( "ScriptEventListener: Event %s, target %s, script %s\n",
event.GetType().CString(),
event.GetTargetElement()->GetTagName().CString(),
script.CString() );
}
if( funcPtr.isValid() ) {
target->AddReference();
event.AddReference();
try {
asIScriptContext *context = asmodule->getContext();
// the context may actually be NULL after AS shutdown
if( context ) {
funcPtr.setContext( context );
funcPtr( target, &event );
}
} catch( ASBind::Exception & ) {
Com_Printf( S_COLOR_RED "ScriptEventListener: Failed to call function %s %s\n", funcName.CString(), script.CString() );
}
}
else {
Com_Printf( S_COLOR_RED "ScriptEventListener: Not gonna call invalid function %s %s\n", funcName.CString(), script.CString() );
}
}
示例2: ProcessEvent
void RocketMenuPlugin::ProcessEvent(Rocket::Core::Event& event) {
Rocket::Core::Element *element = event.GetCurrentElement();
if (event.GetType() == "click") {
if (element->GetTagName() == "ftr") {
SetNextItemValue(element->GetParentNode()->GetParentNode());
event.StopPropagation();
} else if (element->GetTagName() == "hdr") {
SetPreviousItemValue(element->GetParentNode()->GetParentNode());
event.StopPropagation();
} else {
DoItemAction(ItemActionEnter, element);
}
} else if (event.GetType() == "mousemove") {
if (element->GetTagName() == "div") {
HighlightItem(element);
} else if (element->GetTagName() == "key1") {
Rocket::Core::Element *menu_item = element->GetParentNode()->GetParentNode();
SetActiveKeySlot(menu_item, 0);
} else if (element->GetTagName() == "key2") {
Rocket::Core::Element *menu_item = element->GetParentNode()->GetParentNode();
SetActiveKeySlot(menu_item, 1);
}
} else if (event.GetType() == "change") {
if (m_delegate != NULL && element->GetOwnerDocument()->IsVisible()) {
Rocket::Core::Element *menu_item = element->GetParentNode()->GetParentNode();
RangeData *data = GetRangeData(menu_item);
const Rocket::Core::Dictionary *p = event.GetParameters();
float v = p->Get("value")->Get<float>();
float new_value = data->min + v*(data->max - data->min);
if (fabs(new_value-data->value) > 0.001f) {
data->value = new_value;
m_delegate->DidChangeRangeValue(menu_item, data->value);
}
}
}
}