本文整理汇总了C++中EventDispatcher::TriggerEvents方法的典型用法代码示例。如果您正苦于以下问题:C++ EventDispatcher::TriggerEvents方法的具体用法?C++ EventDispatcher::TriggerEvents怎么用?C++ EventDispatcher::TriggerEvents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventDispatcher
的用法示例。
在下文中一共展示了EventDispatcher::TriggerEvents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DispatchEvent
bool EventDispatcher::DispatchEvent(Element* target_element, const String& name, const Dictionary& parameters, bool interruptible)
{
//Event event(target_element, name, parameters, interruptible);
Event* event = Factory::InstanceEvent(target_element, name, parameters, interruptible);
if (event == NULL)
return false;
// Build the element traversal from the tree
typedef std::vector<Element*> Elements;
Elements elements;
Element* walk_element = target_element->GetParentNode();
while (walk_element)
{
elements.push_back(walk_element);
walk_element = walk_element->GetParentNode();
}
event->SetPhase(Event::PHASE_CAPTURE);
// Capture phase - root, to target (only events that have registered as capture events)
// Note: We walk elements in REVERSE as they're placed in the list from the elements parent to the root
for (int i = elements.size() - 1; i >= 0 && event->IsPropagating(); i--)
{
EventDispatcher* dispatcher = elements[i]->GetEventDispatcher();
event->SetCurrentElement(elements[i]);
dispatcher->TriggerEvents(event);
}
// Target phase - direct at the target
if (event->IsPropagating())
{
event->SetPhase(Event::PHASE_TARGET);
event->SetCurrentElement(target_element);
TriggerEvents(event);
}
if (event->IsPropagating())
{
event->SetPhase(Event::PHASE_BUBBLE);
// Bubble phase - target to root (normal event bindings)
for (size_t i = 0; i < elements.size() && event->IsPropagating(); i++)
{
EventDispatcher* dispatcher = elements[i]->GetEventDispatcher();
event->SetCurrentElement(elements[i]);
dispatcher->TriggerEvents(event);
}
}
bool propagating = event->IsPropagating();
event->RemoveReference();
return propagating;
}