*/
/*!
+ \qmlproperty quint32 QtQuick2::KeyEvent::nativeScanCode
+
+ This property contains the native scan code of the key that was pressed. It is
+ passed through from QKeyEvent unchanged.
+
+ \sa QKeyEvent::nativeScanCode()
+*/
+
+/*!
\qmlproperty int QtQuick2::KeyEvent::count
This property holds the number of keys involved in this event. If \l KeyEvent::text
Q_PROPERTY(int modifiers READ modifiers)
Q_PROPERTY(bool isAutoRepeat READ isAutoRepeat)
Q_PROPERTY(int count READ count)
+ Q_PROPERTY(quint32 nativeScanCode READ nativeScanCode)
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
public:
int modifiers() const { return event.modifiers(); }
bool isAutoRepeat() const { return event.isAutoRepeat(); }
int count() const { return event.count(); }
+ quint32 nativeScanCode() const { return event.nativeScanCode(); }
bool isAccepted() { return event.isAccepted(); }
void setAccepted(bool accepted) { event.setAccepted(accepted); }
Q_PROPERTY(bool processLast READ processLast NOTIFY processLastChanged)
public:
- KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0), mLast(false) {}
+ KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0), mLast(false), mNativeScanCode(0) {}
void reset() {
mKey = 0;
mText = QString();
mModifiers = 0;
mForwardedKey = 0;
+ mNativeScanCode = 0;
}
bool processLast() const { return mLast; }
void forwardedKey(int key) {
mForwardedKey = key;
}
+ void specialKey(int key, QString text, quint32 nativeScanCode) {
+ mKey = key;
+ mText = text;
+ mNativeScanCode = nativeScanCode;
+ }
signals:
void processLastChanged();
int mModifiers;
int mForwardedKey;
bool mLast;
+ quint32 mNativeScanCode;
private:
};
testObject->reset();
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_VolumeUp, Qt::NoModifier, 1234, 0, 0);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_VolumeUp));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_VolumeUp));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(testObject->mNativeScanCode == 1234);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(false));
key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
QGuiApplication::sendEvent(canvas, &key);