本文整理汇总了C++中HTMLInputElement::dispatchEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLInputElement::dispatchEvent方法的具体用法?C++ HTMLInputElement::dispatchEvent怎么用?C++ HTMLInputElement::dispatchEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLInputElement
的用法示例。
在下文中一共展示了HTMLInputElement::dispatchEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defaultEventHandler
void SearchFieldCancelButtonElement::defaultEventHandler(Event* event)
{
// If the element is visible, on mouseup, clear the value, and set selection
HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
if (renderer() && renderer()->visibleToHitTesting()) {
if (Frame* frame = document()->frame()) {
frame->eventHandler()->setCapturingMouseEventsNode(this);
m_capturing = true;
}
}
input->focus();
input->select();
event->setDefaultHandled();
}
if (event->type() == eventNames().mouseupEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
if (m_capturing && renderer() && renderer()->visibleToHitTesting()) {
if (Frame* frame = document()->frame()) {
frame->eventHandler()->setCapturingMouseEventsNode(0);
m_capturing = false;
}
if (hovered()) {
RefPtr<HTMLInputElement> protector(input);
String oldValue = input->value();
input->setValue("");
if (!oldValue.isEmpty()) {
toRenderTextControl(input->renderer())->setChangedSinceLastChangeEvent(true);
input->dispatchEvent(Event::create(eventNames().inputEvent, true, false));
}
input->onSearch();
event->setDefaultHandled();
}
}
}
if (!event->defaultHandled())
HTMLDivElement::defaultEventHandler(event);
}
示例2: defaultEventHandler
void SearchFieldCancelButtonElement::defaultEventHandler(Event* event)
{
// If the element is visible, on mouseup, clear the value, and set selection
HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
if (renderer() && renderer()->visibleToHitTesting()) {
if (Frame* frame = document()->frame()) {
frame->eventHandler()->setCapturingMouseEventsNode(this);
m_capturing = true;
}
}
input->focus();
input->select();
event->setDefaultHandled();
}
if (event->type() == eventNames().mouseupEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
if (m_capturing && renderer() && renderer()->visibleToHitTesting()) {
if (Frame* frame = document()->frame()) {
frame->eventHandler()->setCapturingMouseEventsNode(0);
m_capturing = false;
}
#if !PLATFORM(OLYMPIA)
// FIXME: It's always false on OLYMPIA platform. This problem depends on RIM bug #1067.
if (hovered()) {
#else
if (event->target() == this) {
#endif
RefPtr<HTMLInputElement> protector(input);
String oldValue = input->value();
input->setValue("");
if (!oldValue.isEmpty()) {
toRenderTextControl(input->renderer())->setChangedSinceLastChangeEvent(true);
input->dispatchEvent(Event::create(eventNames().inputEvent, true, false));
}
input->onSearch();
event->setDefaultHandled();
}
}
}
if (!event->defaultHandled())
HTMLDivElement::defaultEventHandler(event);
}
// ----------------------------
inline SpinButtonElement::SpinButtonElement(HTMLElement* shadowParent)
: TextControlInnerElement(shadowParent->document(), shadowParent)
, m_capturing(false)
, m_upDownState(Indeterminate)
, m_pressStartingState(Indeterminate)
, m_repeatingTimer(this, &SpinButtonElement::repeatingTimerFired)
{
}
PassRefPtr<SpinButtonElement> SpinButtonElement::create(HTMLElement* shadowParent)
{
return adoptRef(new SpinButtonElement(shadowParent));
}
void SpinButtonElement::defaultEventHandler(Event* event)
{
if (!event->isMouseEvent()) {
if (!event->defaultHandled())
HTMLDivElement::defaultEventHandler(event);
return;
}
RenderBox* box = renderBox();
if (!box) {
if (!event->defaultHandled())
HTMLDivElement::defaultEventHandler(event);
return;
}
HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
if (input->disabled() || input->isReadOnlyFormControl()) {
if (!event->defaultHandled())
HTMLDivElement::defaultEventHandler(event);
return;
}
MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
IntPoint local = roundedIntPoint(box->absoluteToLocal(mouseEvent->absoluteLocation(), false, true));
if (mouseEvent->type() == eventNames().mousedownEvent && mouseEvent->button() == LeftButton) {
if (box->borderBoxRect().contains(local)) {
RefPtr<Node> protector(input);
input->focus();
input->select();
input->stepUpFromRenderer(m_upDownState == Up ? 1 : -1);
event->setDefaultHandled();
startRepeatingTimer();
}
} else if (mouseEvent->type() == eventNames().mouseupEvent && mouseEvent->button() == LeftButton)
stopRepeatingTimer();
else if (event->type() == eventNames().mousemoveEvent) {
if (box->borderBoxRect().contains(local)) {
if (!m_capturing) {
if (Frame* frame = document()->frame()) {
frame->eventHandler()->setCapturingMouseEventsNode(this);
//.........这里部分代码省略.........