本文整理汇总了C++中EventDispatcher::dispatch方法的典型用法代码示例。如果您正苦于以下问题:C++ EventDispatcher::dispatch方法的具体用法?C++ EventDispatcher::dispatch怎么用?C++ EventDispatcher::dispatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventDispatcher
的用法示例。
在下文中一共展示了EventDispatcher::dispatch方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST( EventDispatcherTest, Dispatching )
{
using namespace StevensDev::sgde;
using namespace StevensDev::sgdt;
EventDispatcher d;
TestListener listener;
TestEvent event;
EventListener callback = std::bind(
&TestListener::receive, &listener, std::placeholders::_1 );
// ensure added callbacks are called
EventHandle handle = d.add( TestEvent::DEFAULT_TYPE, callback );
d.postTick();
d.dispatch( &event );
EXPECT_TRUE( listener.wasCalled() );
EXPECT_STREQ( TestEvent::DEFAULT_TYPE.c_str(),
listener.receivedType().c_str() );
// ensure removed callbacks are no longer called
d.remove( TestEvent::DEFAULT_TYPE, handle );
d.postTick();
listener.reset();
d.dispatch( &event );
EXPECT_FALSE( listener.wasCalled() );
}
示例2: event
bool MouseEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) const
{
if (isSyntheticMouseEvent()) {
event().eventPath().adjustForRelatedTarget(dispatcher.node(), event().relatedTarget());
return dispatcher.dispatch();
}
if (isDisabledFormControl(&dispatcher.node()))
return false;
if (event().type().isEmpty())
return true; // Shouldn't happen.
ASSERT(!event().target() || event().target() != event().relatedTarget());
EventTarget* relatedTarget = event().relatedTarget();
event().eventPath().adjustForRelatedTarget(dispatcher.node(), relatedTarget);
dispatcher.dispatch();
bool swallowEvent = event().defaultHandled() || event().defaultPrevented();
if (event().type() != EventTypeNames::click || event().detail() != 2)
return !swallowEvent;
// Special case: If it's a double click event, we also send the dblclick event. This is not part
// of the DOM specs, but is used for compatibility with the ondblclick="" attribute. This is treated
// as a separate event in other DOM-compliant browsers like Firefox, and so we do the same.
RefPtrWillBeRawPtr<MouseEvent> doubleClickEvent = MouseEvent::create();
doubleClickEvent->initMouseEvent(nullptr, EventTypeNames::dblclick, event().bubbles(), event().cancelable(), event().view(),
event().detail(), event().screenX(), event().screenY(), event().clientX(), event().clientY(),
event().ctrlKey(), event().altKey(), event().shiftKey(), event().metaKey(),
event().button(), relatedTarget, event().buttons());
if (event().defaultHandled())
doubleClickEvent->setDefaultHandled();
EventDispatcher::dispatchEvent(dispatcher.node(), MouseEventDispatchMediator::create(doubleClickEvent));
if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented())
return false;
return !swallowEvent;
}
示例3: dispatchEvent
DispatchEventResult InputEventDispatchMediator::dispatchEvent(
EventDispatcher& dispatcher) const {
DispatchEventResult result = dispatcher.dispatch();
// It's weird to hold and clear live |Range| objects internally, and only
// expose |StaticRange| through |getTargetRanges()|. However there is no
// better solutions due to the following issues:
// 1. We don't want to expose live |Range| objects for the author to hold as
// it will slow down all DOM operations. So we just expose |StaticRange|.
// 2. Event handlers in chain might modify DOM, which means we have to keep
// a copy of live |Range| internally and return snapshots.
// 3. We don't want authors to hold live |Range| indefinitely by holding
// |InputEvent|, so we clear them after dispatch.
// Authors should explicitly call |getTargetRanges()|->|toRange()| if they
// want to keep a copy of |Range|. See Editing TF meeting notes:
// https://docs.google.com/document/d/1hCj6QX77NYIVY0RWrMHT1Yra6t8_Qu8PopaWLG0AM58/edit?usp=sharing
event().m_ranges.clear();
return result;
}
示例4: processWaitingList
void FinishingStations::processWaitingList(SimulationState& state) {
while (!state.employees().empty()
&& !empty()
&& waiting()) {
state.employees().acquire();
dequeue();
acquire();
TracerService* tracer = ServiceLocator::instance().findTracerService();
tracer->log(state.clock().now(), "1 garment begins finishing treatment.");
EventDispatcher* dispatcher = ServiceLocator::instance().findDispatcherService();
RandomService<int>* random = ServiceLocator::instance().findRandomService();
Event event(state.clock().now() + random->next(state.finishingProcTimeDist()));
event.setHandler(new FinishingEndHandler());
dispatcher->dispatch(event);
}
}
示例5: dispatchEvent
DispatchEventResult EventDispatchMediator::dispatchEvent(
EventDispatcher& dispatcher) const {
DCHECK_EQ(m_event.get(), &dispatcher.event());
return dispatcher.dispatch();
}
示例6: dispatchEvent
bool GestureEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) const
{
dispatcher.dispatch();
ASSERT(!event().defaultPrevented());
return event().defaultHandled() || event().defaultPrevented();
}
示例7: dispatchEvent
bool TouchEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) const
{
event().eventPath().adjustForTouchEvent(event());
return dispatcher.dispatch();
}
示例8: dispatchEvent
DispatchEventResult EventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) const
{
ASSERT(m_event.get() == &dispatcher.event());
return dispatcher.dispatch();
}