本文整理汇总了C++中EventHandler::GetEventType方法的典型用法代码示例。如果您正苦于以下问题:C++ EventHandler::GetEventType方法的具体用法?C++ EventHandler::GetEventType怎么用?C++ EventHandler::GetEventType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventHandler
的用法示例。
在下文中一共展示了EventHandler::GetEventType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UnsubscribeFromEventReceiver
void Object::UnsubscribeFromEventReceiver(Object* receiver)
{
EventHandler* handler = eventHandlers_.First();
EventHandler* previous = 0;
while (handler)
{
if (handler->GetReceiver() == receiver)
{
if (handler->GetSender())
context_->RemoveEventReceiver(this, handler->GetSender(), handler->GetEventType());
else
context_->RemoveEventReceiver(this, handler->GetEventType());
EventHandler* next = eventHandlers_.Next(handler);
eventHandlers_.Erase(handler, previous);
handler = next;
}
else
{
previous = handler;
handler = eventHandlers_.Next(handler);
}
}
}
示例2: UnsubscribeFromAllEvents
void Object::UnsubscribeFromAllEvents()
{
for (;;)
{
EventHandler* handler = eventHandlers_.First();
if (handler)
{
if (handler->GetSender())
context_->RemoveEventReceiver(this, handler->GetSender(), handler->GetEventType());
else
context_->RemoveEventReceiver(this, handler->GetEventType());
eventHandlers_.Erase(handler);
}
else
break;
}
}
示例3: UnsubscribeFromAllEventsExcept
void Object::UnsubscribeFromAllEventsExcept(const PODVector<StringHash>& exceptions, bool onlyUserData)
{
EventHandler* handler = eventHandlers_.First();
EventHandler* previous = 0;
while (handler)
{
EventHandler* next = eventHandlers_.Next(handler);
if ((!onlyUserData || handler->GetUserData()) && !exceptions.Contains(handler->GetEventType()))
{
if (handler->GetSender())
context_->RemoveEventReceiver(this, handler->GetSender(), handler->GetEventType());
else
context_->RemoveEventReceiver(this, handler->GetEventType());
eventHandlers_.Erase(handler, previous);
}
else
previous = handler;
handler = next;
}
}
示例4: FindSpecificEventHandler
EventHandler* Object::FindSpecificEventHandler(Object* sender, StringHash eventType, EventHandler** previous) const
{
EventHandler* handler = eventHandlers_.First();
if (previous)
*previous = 0;
while (handler)
{
if (handler->GetSender() == sender && handler->GetEventType() == eventType)
return handler;
if (previous)
*previous = handler;
handler = eventHandlers_.Next(handler);
}
return 0;
}
示例5: FindEventHandler
EventHandler* Object::FindEventHandler(StringHash eventType, EventHandler** previous) const
{
EventHandler* handler = eventHandlers_.First();
if (previous)
*previous = 0;
while (handler)
{
if (handler->GetEventType() == eventType)
return handler;
if (previous)
*previous = handler;
handler = eventHandlers_.Next(handler);
}
return 0;
}
示例6: UnsubscribeFromEvents
void Object::UnsubscribeFromEvents(Object* sender)
{
if (!sender)
return;
for (;;)
{
EventHandler* previous;
EventHandler* handler = FindSpecificEventHandler(sender, &previous);
if (handler)
{
context_->RemoveEventReceiver(this, handler->GetSender(), handler->GetEventType());
eventHandlers_.Erase(handler, previous);
}
else
break;
}
}
示例7: OnEvent
void Object::OnEvent(Object* sender, StringHash eventType, VariantMap& eventData)
{
// Make a copy of the context pointer in case the object is destroyed during event handler invocation
Context* context = context_;
EventHandler* specific = 0;
EventHandler* nonSpecific = 0;
EventHandler* handler = eventHandlers_.First();
while (handler)
{
if (handler->GetEventType() == eventType)
{
if (!handler->GetSender())
nonSpecific = handler;
else if (handler->GetSender() == sender)
{
specific = handler;
break;
}
}
handler = eventHandlers_.Next(handler);
}
// Specific event handlers have priority, so if found, invoke first
if (specific)
{
context->SetEventHandler(specific);
specific->Invoke(eventData);
context->SetEventHandler(0);
return;
}
if (nonSpecific)
{
context->SetEventHandler(nonSpecific);
nonSpecific->Invoke(eventData);
context->SetEventHandler(0);
}
}