PassRefPtr<MouseEvent> MouseEvent::create(const AtomicString& eventType, PassRefPtr<AbstractView> view, const PlatformMouseEvent& event, int detail, PassRefPtr<Node> relatedTarget) { ASSERT(event.eventType() == MouseEventMoved || event.button() != NoButton); bool isCancelable = eventType != eventNames().mousemoveEvent; return MouseEvent::create(eventType, true, isCancelable, view, detail, event.globalX(), event.globalY(), event.x(), event.y(), event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), event.button(), relatedTarget, 0, false); }
bool EventTargetNode::dispatchMouseEvent(const PlatformMouseEvent& _mouse, const AtomicString& eventType, int detail, Node* relatedTarget) { assert(!eventDispatchForbidden()); IntPoint contentsPos; if (FrameView* view = document()->view()) contentsPos = view->viewportToContents(_mouse.pos()); return dispatchMouseEvent(eventType, _mouse.button(), detail, contentsPos.x(), contentsPos.y(), _mouse.globalX(), _mouse.globalY(), _mouse.ctrlKey(), _mouse.altKey(), _mouse.shiftKey(), _mouse.metaKey(), false, relatedTarget); }
bool EventTargetNode::dispatchMouseEvent(const PlatformMouseEvent& event, const AtomicString& eventType, int detail, Node* relatedTarget) { ASSERT(!eventDispatchForbidden()); IntPoint contentsPos; if (FrameView* view = document()->view()) contentsPos = view->windowToContents(event.pos()); short button = event.button(); ASSERT(event.eventType() == MouseEventMoved || button != NoButton); return dispatchMouseEvent(eventType, button, detail, contentsPos.x(), contentsPos.y(), event.globalX(), event.globalY(), event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), false, relatedTarget); }
bool PlatformScrollbar::handleContextMenuEvent(const PlatformMouseEvent& event) { #ifndef QT_NO_CONTEXTMENU bool horizontal = (m_orientation == HorizontalScrollbar); QMenu menu; QAction* actScrollHere = menu.addAction(tr("Scroll here")); menu.addSeparator(); QAction* actScrollTop = menu.addAction(horizontal ? tr("Left edge") : tr("Top")); QAction* actScrollBottom = menu.addAction(horizontal ? tr("Right edge") : tr("Bottom")); menu.addSeparator(); QAction* actPageUp = menu.addAction(horizontal ? tr("Page left") : tr("Page up")); QAction* actPageDown = menu.addAction(horizontal ? tr("Page right") : tr("Page down")); menu.addSeparator(); QAction* actScrollUp = menu.addAction(horizontal ? tr("Scroll left") : tr("Scroll up")); QAction* actScrollDown = menu.addAction(horizontal ? tr("Scroll right") : tr("Scroll down")); const QPoint globalPos = QPoint(event.globalX(), event.globalY()); QAction* actionSelected = menu.exec(globalPos); if (actionSelected == 0) /* Do nothing */ ; else if (actionSelected == actScrollHere) { const QPoint pos = convertFromContainingWindow(event.pos()); setValue(pixelPosToRangeValue(horizontal ? pos.x() : pos.y())); } else if (actionSelected == actScrollTop) setValue(0); else if (actionSelected == actScrollBottom) setValue(m_totalSize - m_visibleSize); else if (actionSelected == actPageUp) scroll(horizontal ? ScrollLeft: ScrollUp, ScrollByPage, 1); else if (actionSelected == actPageDown) scroll(horizontal ? ScrollRight : ScrollDown, ScrollByPage, 1); else if (actionSelected == actScrollUp) scroll(horizontal ? ScrollLeft : ScrollUp, ScrollByLine, 1); else if (actionSelected == actScrollDown) scroll(horizontal ? ScrollRight : ScrollDown, ScrollByLine, 1); #endif // QT_NO_CONTEXTMENU return true; }