1/****************************************************************************
2**
3** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt3D module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qkeyevent.h"
41
42QT_BEGIN_NAMESPACE
43
44namespace Qt3DInput {
45
46//Qt6: Move this into a QtQmlGui module and merge it with QQuickKeyEvent
47
48/*!
49 \class Qt3DInput::QKeyEvent
50 \inmodule Qt3DInput
51 \brief QKeyEvent event type send by KeyBoardHandler.
52 \since 5.5
53 \brief Contains parameters that describe a key event
54*/
55
56/*!
57 \qmltype KeyEvent
58 \inqmlmodule Qt3D.Input
59 \instantiates Qt3DInput::QKeyEvent
60 \brief QML frontend for QKeyEvent C++ class.
61 \since 5.5
62 \brief Contains parameters that describe a key event
63
64 The KeyEvent QML type cannot be directly created. Objects of this type
65 are used as signal parameters in KeyboardHandler.
66*/
67
68/*!
69 * \typedef Qt3DInput::QKeyEventPtr
70 * \relates Qt3DInput::QKeyEvent
71 *
72 * A shared pointer for QKeyEvent.
73 */
74
75QKeyEvent::QKeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text, bool autorep, ushort count)
76 : QObject()
77 , m_event(type, key, modifiers, text, autorep, count)
78{
79 m_event.setAccepted(false);
80}
81
82QKeyEvent::QKeyEvent(const QT_PREPEND_NAMESPACE(QKeyEvent) &ke)
83 : QObject()
84 , m_event(ke)
85{
86 m_event.setAccepted(false);
87}
88
89/*! \internal */
90QKeyEvent::~QKeyEvent()
91{
92}
93
94/*!
95 \qmlproperty int Qt3D.Input::KeyEvent::key
96 \readonly
97
98 This property holds the code of the key that was pressed or released.
99
100 See \l [CPP] {Qt::Key}{Qt.Key} for the list of keyboard codes.
101
102 \sa {QtQuick::KeyEvent::key}{KeyEvent.key}
103*/
104
105/*!
106 \qmlproperty string Qt3D.Input::KeyEvent::text
107 \readonly
108
109 This property holds the Unicode text that the key generated. The text
110 returned can be an empty string in cases where modifier keys, such as
111 Shift, Control, Alt, and Meta, are being pressed or released. In such
112 cases \l key will contain a valid value.
113*/
114
115/*!
116 \qmlproperty int Qt3D.Input::KeyEvent::modifiers
117 \readonly
118
119 This property holds the keyboard modifier flags that existed immediately
120 before the event occurred.
121
122 \sa {QtQuick::KeyEvent::modifiers}{KeyEvent.modifiers}
123*/
124
125/*!
126 \qmlproperty bool Qt3D.Input::KeyEvent::isAutoRepeat
127 \readonly
128
129 Holds whether this event comes from an auto-repeating key.
130*/
131
132/*!
133 \qmlproperty int Qt3D.Input::KeyEvent::count
134 \readonly
135
136 Holds the number of keys involved in this event. If \l text is not empty,
137 this is simply the length of the string.
138*/
139
140/*!
141 \qmlproperty quint32 Qt3D.Input::KeyEvent::nativeScanCode
142 \readonly
143
144 This property contains the native scan code of the key that was pressed.
145 It is passed through from QKeyEvent unchanged.
146
147 \sa QKeyEvent::nativeScanCode()
148*/
149
150/*!
151 \qmlproperty bool Qt3D.Input::KeyEvent::accepted
152
153 Setting \e accepted to \c true prevents the key event from being propagated
154 to the item's parent.
155
156 Generally, if the item acts on the key event then it should be accepted so
157 that ancestor items do not also respond to the same event.
158*/
159
160/*!
161 \qmlmethod bool Qt3D.Input::KeyEvent::matches(StandardKey key)
162
163 Returns \c true if the key event matches the given standard \a key; otherwise
164 returns \c false.
165
166 \sa QKeySequence::StandardKey
167*/
168
169/*!
170 \property Qt3DInput::QKeyEvent::key
171 \readonly
172
173 This property holds the code of the key that was pressed or released.
174
175 See \l [CPP] {Qt::Key}{Qt.Key} for the list of keyboard codes.
176
177 \b {See also} \l [QtGui] {QKeyEvent::key()}.
178*/
179
180/*!
181 \property Qt3DInput::QKeyEvent::text
182 \readonly
183
184 This property holds the Unicode text that the key generated. The text
185 returned can be an empty string in cases where modifier keys, such as
186 Shift, Control, Alt, and Meta, are being pressed or released. In such
187 cases \l key will contain a valid value.
188*/
189
190/*!
191 \property Qt3DInput::QKeyEvent::modifiers
192 \readonly
193
194 This property holds the keyboard modifier flags that existed immediately
195 before the event occurred.
196
197 \b {See also} \l [QtGui] {QKeyEvent::modifiers()}.
198*/
199
200/*!
201 \property Qt3DInput::QKeyEvent::isAutoRepeat
202 \readonly
203
204 Holds whether this event comes from an auto-repeating key.
205*/
206
207/*!
208 \property Qt3DInput::QKeyEvent::count
209 \readonly
210
211 Holds the number of keys involved in this event. If \l text is not empty,
212 this is simply the length of the string.
213*/
214
215/*!
216 \property Qt3DInput::QKeyEvent::nativeScanCode
217 \readonly
218
219 This property contains the native scan code of the key that was pressed.
220 It is passed through from QKeyEvent unchanged.
221
222*/
223
224/*!
225 \property Qt3DInput::QKeyEvent::accepted
226
227 Setting \e accepted to \c true prevents the key event from being propagated
228 to the item's parent.
229
230 Generally, if the item acts on the key event then it should be accepted so
231 that ancestor items do not also respond to the same event.
232*/
233
234/*!
235 \fn bool Qt3DInput::QKeyEvent::matches(QKeySequence::StandardKey key_) const
236
237 Returns \c true if the key event matches the given standard key \a key_; otherwise
238 returns \c false.
239
240 \sa QKeySequence::StandardKey
241*/
242
243/*!
244 \fn QEvent::Type Qt3DInput::QKeyEvent::type() const
245 Returns the type of the event.
246
247*/
248
249} // namespace Qt3DInput
250
251QT_END_NAMESPACE
252

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