本文整理汇总了C++中CMouse::PutMouseEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ CMouse::PutMouseEvent方法的具体用法?C++ CMouse::PutMouseEvent怎么用?C++ CMouse::PutMouseEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMouse
的用法示例。
在下文中一共展示了CMouse::PutMouseEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: captureMouse
void UIMouseHandler::captureMouse(ulong uScreenId)
{
/* Do not try to capture mouse if its captured already: */
if (uisession()->isMouseCaptured())
return;
/* If such viewport exists: */
if (m_viewports.contains(uScreenId))
{
/* Store mouse-capturing state value: */
uisession()->setMouseCaptured(true);
/* Memorize the index of machine-view-viewport captured mouse: */
m_iMouseCaptureViewIndex = uScreenId;
/* Memorize the host position where the cursor was captured: */
m_capturedMousePos = QCursor::pos();
/* Acquiring visible viewport rectangle in global coodrinates: */
QRect visibleRectangle = m_viewports[m_iMouseCaptureViewIndex]->visibleRegion().boundingRect();
QPoint visibleRectanglePos = m_views[m_iMouseCaptureViewIndex]->mapToGlobal(m_viewports[m_iMouseCaptureViewIndex]->pos());
visibleRectangle.translate(visibleRectanglePos);
visibleRectangle = visibleRectangle.intersected(QApplication::desktop()->availableGeometry());
#ifdef Q_WS_WIN
/* Move the mouse to the center of the visible area: */
m_lastMousePos = visibleRectangle.center();
QCursor::setPos(m_lastMousePos);
/* Update mouse clipping: */
updateMouseCursorClipping();
#elif defined (Q_WS_MAC)
/* Grab all mouse events: */
::darwinMouseGrab(m_viewports[m_iMouseCaptureViewIndex]);
#else /* Q_WS_MAC */
/* Remember current mouse position: */
m_lastMousePos = QCursor::pos();
/* Grab all mouse events: */
m_viewports[m_iMouseCaptureViewIndex]->grabMouse();
#endif /* !Q_WS_MAC */
/* Switch guest mouse to the relative mode: */
CMouse mouse = session().GetConsole().GetMouse();
mouse.PutMouseEvent(0, 0, 0, 0, 0);
/* Emit signal if required: */
emit mouseStateChanged(mouseState());
}
}