本文整理汇总了C++中EventPath::contextAt方法的典型用法代码示例。如果您正苦于以下问题:C++ EventPath::contextAt方法的具体用法?C++ EventPath::contextAt怎么用?C++ EventPath::contextAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventPath
的用法示例。
在下文中一共展示了EventPath::contextAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: callDefaultEventHandlersInTheBubblingOrder
static void callDefaultEventHandlersInTheBubblingOrder(Event& event, const EventPath& path)
{
// Non-bubbling events call only one default event handler, the one for the target.
path.contextAt(0).node()->defaultEventHandler(&event);
ASSERT(!event.defaultPrevented());
if (event.defaultHandled() || !event.bubbles())
return;
size_t size = path.size();
for (size_t i = 1; i < size; ++i) {
path.contextAt(i).node()->defaultEventHandler(&event);
ASSERT(!event.defaultPrevented());
if (event.defaultHandled())
return;
}
}
示例2: dispatchEventInDOM
static void dispatchEventInDOM(Event& event, const EventPath& path, WindowEventContext& windowEventContext)
{
// Trigger capturing event handlers, starting at the top and working our way down.
event.setEventPhase(Event::CAPTURING_PHASE);
// We don't dispatch load events to the window. This quirk was originally
// added because Mozilla doesn't propagate load events to the window object.
bool shouldFireEventAtWindow = event.type() != eventNames().loadEvent;
if (shouldFireEventAtWindow && windowEventContext.handleLocalEvents(event) && event.propagationStopped())
return;
for (size_t i = path.size() - 1; i > 0; --i) {
const EventContext& eventContext = path.contextAt(i);
if (eventContext.currentTargetSameAsTarget())
continue;
eventContext.handleLocalEvents(event);
if (event.propagationStopped())
return;
}
event.setEventPhase(Event::AT_TARGET);
path.contextAt(0).handleLocalEvents(event);
if (event.propagationStopped())
return;
// Trigger bubbling event handlers, starting at the bottom and working our way up.
size_t size = path.size();
for (size_t i = 1; i < size; ++i) {
const EventContext& eventContext = path.contextAt(i);
if (eventContext.currentTargetSameAsTarget())
event.setEventPhase(Event::AT_TARGET);
else if (event.bubbles() && !event.cancelBubble())
event.setEventPhase(Event::BUBBLING_PHASE);
else
continue;
eventContext.handleLocalEvents(event);
if (event.propagationStopped())
return;
}
if (event.bubbles() && !event.cancelBubble()) {
event.setEventPhase(Event::BUBBLING_PHASE);
if (shouldFireEventAtWindow)
windowEventContext.handleLocalEvents(event);
}
}