当前位置: 首页>>代码示例>>C++>>正文


C++ EventDispatcher::TriggerEvents方法代码示例

本文整理汇总了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;
}
开发者ID:ABuus,项目名称:RuntimeCompiledCPlusPlus,代码行数:52,代码来源:EventDispatcher.cpp


注:本文中的EventDispatcher::TriggerEvents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。