1// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QT3DINPUT_QKEYEVENT_H
5#define QT3DINPUT_QKEYEVENT_H
6
7#include <Qt3DInput/qt3dinput_global.h>
8#include <QtCore/QObject>
9#include <QtGui/QKeyEvent>
10#include <memory>
11
12QT_BEGIN_NAMESPACE
13
14namespace Qt3DInput {
15
16class QKeyEventPrivate;
17class QKeyEvent;
18
19typedef QSharedPointer<QKeyEvent> QKeyEventPtr;
20
21class Q_3DINPUTSHARED_EXPORT QKeyEvent : public QObject
22{
23 Q_OBJECT
24 Q_PROPERTY(int key READ key CONSTANT)
25 Q_PROPERTY(QString text READ text CONSTANT)
26 Q_PROPERTY(int modifiers READ modifiers CONSTANT)
27 Q_PROPERTY(bool isAutoRepeat READ isAutoRepeat CONSTANT)
28 Q_PROPERTY(int count READ count CONSTANT)
29 Q_PROPERTY(quint32 nativeScanCode READ nativeScanCode CONSTANT)
30 Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
31
32public:
33 explicit QKeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text=QString(), bool autorep=false, ushort count=1);
34 explicit QKeyEvent(const QT_PREPEND_NAMESPACE(QKeyEvent) &ke);
35 ~QKeyEvent();
36
37 inline int key() const { return m_event->key(); }
38 inline QString text() const { return m_event->text(); }
39 inline int modifiers() const { return int(m_event->modifiers().toInt()); }
40 inline bool isAutoRepeat() const { return m_event->isAutoRepeat(); }
41 inline int count() const { return m_event->count(); }
42 inline quint32 nativeScanCode() const { return m_event->nativeScanCode(); }
43 inline bool isAccepted() const { return m_event->isAccepted(); }
44 inline void setAccepted(bool accepted) { m_event->setAccepted(accepted); }
45 inline QEvent::Type type() const { return m_event->type(); }
46#if QT_CONFIG(shortcut)
47 Q_INVOKABLE bool matches(QKeySequence::StandardKey key_) const { return m_event->matches(key: key_); }
48#endif
49
50private:
51 std::unique_ptr<QT_PREPEND_NAMESPACE(QKeyEvent)> m_event;
52};
53
54} // namespace Qt3DInput
55
56QT_END_NAMESPACE
57
58#endif // QT3DINPUT_QKEYEVENT_H
59

source code of qt3d/src/input/frontend/qkeyevent.h