bool ToolBarEventFilter::eventFilter (QObject *watched, QEvent *event) { if (watched != m_toolBar) return QObject::eventFilter (watched, event); switch (event->type()) { case QEvent::ChildAdded: { // Children should not interact with the mouse const QChildEvent *ce = static_cast<const QChildEvent *>(event); if (QWidget *w = qobject_cast<QWidget *>(ce->child())) { w->setAttribute(Qt::WA_TransparentForMouseEvents, true); w->setFocusPolicy(Qt::NoFocus); } } break; case QEvent::ContextMenu: return handleContextMenuEvent(static_cast<QContextMenuEvent*>(event)); case QEvent::DragEnter: case QEvent::DragMove: return handleDragEnterMoveEvent(static_cast<QDragMoveEvent *>(event)); case QEvent::DragLeave: return handleDragLeaveEvent(static_cast<QDragLeaveEvent *>(event)); case QEvent::Drop: return handleDropEvent(static_cast<QDropEvent *>(event)); case QEvent::MouseButtonPress: return handleMousePressEvent(static_cast<QMouseEvent*>(event)); case QEvent::MouseButtonRelease: return handleMouseReleaseEvent(static_cast<QMouseEvent*>(event)); case QEvent::MouseMove: return handleMouseMoveEvent(static_cast<QMouseEvent*>(event)); default: break; } return QObject::eventFilter (watched, event); }
void NcWidgetData::handleWidgetEvent( QEvent* event ) { switch ( event->type() ) { default: //qDebug() << "Event = " << event; break; case QEvent::MouseButtonPress: handleMousePressEvent( static_cast<QMouseEvent*>( event ) ); break; case QEvent::MouseButtonRelease: handleMouseReleaseEvent( static_cast<QMouseEvent*>( event ) ); break; case QEvent::MouseMove: handleMouseMoveEvent( static_cast<QMouseEvent*>( event ) ); break; case QEvent::Leave: handleLeaveEvent( event ); break; //Bug fix, hover event is necessary coz child widget does not //propagate mousemove events. so the cursor remains in edge shape //even in middle of widget. case QEvent::HoverMove: handleHoverMoveEvent( static_cast<QHoverEvent*>( event ) ); break; //case QEvent::Enter: //qDebug() << "Enter event";//d->handleEnterEvent( event ); //break; } }
// taken from libqtxdg: XdgMenuWidget bool XdgCachedMenu::event(QEvent* event) { if (event->type() == QEvent::MouseButtonPress) { QMouseEvent *e = static_cast<QMouseEvent*>(event); if (e->button() == Qt::LeftButton) mDragStartPosition = e->pos(); } else if (event->type() == QEvent::MouseMove) { QMouseEvent *e = static_cast<QMouseEvent*>(event); handleMouseMoveEvent(e); } else if(event->type() == QEvent::ToolTip) { QHelpEvent* helpEvent = static_cast<QHelpEvent*>(event); QAction* action = actionAt(helpEvent->pos()); if(action && action->menu() == NULL) QToolTip::showText(helpEvent->globalPos(), action->toolTip(), this); } return QMenu::event(event); }
void QtWebPageEventHandler::handleHoverMoveEvent(QHoverEvent* ev) { QTransform fromItemTransform = m_webPage->transformFromItem(); QMouseEvent me(QEvent::MouseMove, fromItemTransform.map(ev->posF()), Qt::NoButton, Qt::NoButton, Qt::NoModifier); me.setAccepted(ev->isAccepted()); me.setTimestamp(ev->timestamp()); handleMouseMoveEvent(&me); }
void QtWebPageEventHandler::handleHoverMoveEvent(QHoverEvent* ev) { QMouseEvent me(QEvent::MouseMove, ev->posF(), Qt::NoButton, Qt::NoButton, Qt::NoModifier); me.setAccepted(ev->isAccepted()); me.setTimestamp(ev->timestamp()); // This will apply the transform on the event. handleMouseMoveEvent(&me); }
void InputComponent::onEvent(Event* e) { EventType type = e->getType(); if(type == EVENT_RUMBLE) { handleRumbleEvent(static_cast<Event_Rumble*>(e)); } if(type == EVENT_MOUSE_MOVE) { handleMouseMoveEvent(static_cast<Event_MouseMove*>(e)); } if(type == EVENT_KEY_PRESS) { Event_KeyPress* ekp = static_cast<Event_KeyPress*>(e); int keyEnum = ekp->keyEnum; bool isPressed = ekp->isPressed; bool shiftPressed = ekp->shiftPressed; bool tabPressed = ekp->tabPressed; handleKeyEvent(keyEnum, isPressed, shiftPressed, tabPressed); } if(type == EVENT_MOUSE_PRESS) { Event_MousePress* emp = static_cast<Event_MousePress*>(e); int keyEnum = emp->keyEnum; bool isPressed = emp->isPressed; handleMousePressedEvent(keyEnum, isPressed); } if(type == EVENT_INPUT_DEVICE_SEARCH) { inputManager_->UpdateNumberOfGamepads(windowHandle_); } if(type == EVENT_START_DEATHMATCH) { setupPlayerControllerConnection(); } if(type == EVENT_MOUSE_WHEEL) { Event_MouseWheel* emw = static_cast<Event_MouseWheel*>(e); QTInputDevices* device = inputManager_->GetMouseAndKeyboard(); if(device != nullptr) { if(emw->value >= 0) { //device->setScrollButton(true); handleKeyEvent('â', true); } else { //device->setScrollButton(false); handleKeyEvent('ô', true); } } } }
void RGraphicsView::simulateMouseMoveEvent() { if (lastKnownScreenPosition.isValid()) { RMouseEvent e(QEvent::MouseMove, lastKnownScreenPosition, Qt::NoButton, Qt::NoButton, Qt::NoModifier, *getScene(), *this); if (lastKnownModelPosition.isValid()) { e.setModelPosition(lastKnownModelPosition); } handleMouseMoveEvent(e); } }
void VMdEditor::mouseMoveEvent(QMouseEvent *p_event) { if (handleMouseMoveEvent(p_event)) { return; } VTextEdit::mouseMoveEvent(p_event); emit m_object->mouseMoved(p_event); }