当前位置: 首页>>代码示例>>C++>>正文


C++ QWaylandInputDevice::sendFullKeyEvent方法代码示例

本文整理汇总了C++中QWaylandInputDevice::sendFullKeyEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ QWaylandInputDevice::sendFullKeyEvent方法的具体用法?C++ QWaylandInputDevice::sendFullKeyEvent怎么用?C++ QWaylandInputDevice::sendFullKeyEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QWaylandInputDevice的用法示例。


在下文中一共展示了QWaylandInputDevice::sendFullKeyEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: eventFilter

bool LipstickCompositorWindow::eventFilter(QObject *obj, QEvent *event)
{
#if QT_VERSION >= 0x050202
    if (obj == window() && m_interceptingTouch) {
        switch (event->type()) {
        case QEvent::TouchUpdate: {
            QTouchEvent *te = static_cast<QTouchEvent *>(event);
            // If we get press/release, don't intercept the event, but send it through QQuickWindow.
            // These are sent through to QQuickWindow so that the integrity of the touch
            // handling is maintained.
            if (te->touchPointStates() & (Qt::TouchPointPressed | Qt::TouchPointReleased))
                return false;
            handleTouchEvent(static_cast<QTouchEvent *>(event));
            return true;
        }
        case QEvent::TouchEnd: // Intentional fall through...
        case QEvent::TouchCancel:
            obj->removeEventFilter(this);
            m_interceptingTouch = false;
        default:
            break;
        }
        return false;
    }
#else
    Q_UNUSED(obj);
#endif
    if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
        QKeyEvent *ke = static_cast<QKeyEvent *>(event);
        QWaylandSurface *m_surface = surface();
        if (m_surface && (m_grabbedKeys.contains(ke->key()) || m_pressedGrabbedKeys.keys.contains(ke->key())) && !ke->isAutoRepeat()) {
            QWaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice();
            if (event->type() == QEvent::KeyPress) {
                if (m_pressedGrabbedKeys.keys.isEmpty()) {
                    QWaylandSurface *old = inputDevice->keyboardFocus();
                    m_pressedGrabbedKeys.oldFocus = old;
                    inputDevice->setKeyboardFocus(m_surface);
                }
                m_pressedGrabbedKeys.keys << ke->key();
            }
            inputDevice->sendFullKeyEvent(ke);
            if (event->type() == QEvent::KeyRelease) {
                m_pressedGrabbedKeys.keys.removeOne(ke->key());
                if (m_pressedGrabbedKeys.keys.isEmpty()) {
                    inputDevice->setKeyboardFocus(m_pressedGrabbedKeys.oldFocus);
                    if (m_grabbedKeys.isEmpty())
                        qApp->removeEventFilter(this);
                }
            }
            return true;
        }
    }
    return false;
}
开发者ID:martyone,项目名称:lipstick,代码行数:54,代码来源:lipstickcompositorwindow.cpp

示例2: eventFilter

bool LipstickCompositorWindow::eventFilter(QObject *, QEvent *event)
{
    if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
        QKeyEvent *ke = static_cast<QKeyEvent *>(event);
        QWaylandSurface *m_surface = surface();
        if (m_surface && m_grabbedKeys.contains(ke->key())) {
            QWaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice();
            inputDevice->sendFullKeyEvent(m_surface, ke);

            return true;
        }
    }
    return false;
}
开发者ID:blammit,项目名称:lipstick,代码行数:14,代码来源:lipstickcompositorwindow.cpp


注:本文中的QWaylandInputDevice::sendFullKeyEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。