diff --git a/interface/resources/qml/controls-uit/Key.qml b/interface/resources/qml/controls-uit/Key.qml index 2218474936..0c888d1a0a 100644 --- a/interface/resources/qml/controls-uit/Key.qml +++ b/interface/resources/qml/controls-uit/Key.qml @@ -34,7 +34,10 @@ Item { onClicked: { mouse.accepted = true; + webEntity.synthesizeKeyPress(glyph); + webEntity.synthesizeKeyPress(glyph, mirrorText); + if (toggle) { toggled = !toggled; } diff --git a/interface/resources/qml/controls-uit/Keyboard.qml b/interface/resources/qml/controls-uit/Keyboard.qml index 07488fe3e6..4739534fcd 100644 --- a/interface/resources/qml/controls-uit/Keyboard.qml +++ b/interface/resources/qml/controls-uit/Keyboard.qml @@ -9,6 +9,7 @@ // import QtQuick 2.0 +import "." Item { id: keyboardBase @@ -16,9 +17,15 @@ Item { property bool raised: false property bool numeric: false + readonly property int keyboardRowHeight: 50 + readonly property int keyboardWidth: 480 + + readonly property int mirrorTextHeight: keyboardRowHeight + + property bool showMirrorText: true readonly property int raisedHeight: 200 - height: enabled && raised ? raisedHeight : 0 + height: enabled && raised ? raisedHeight + (showMirrorText ? keyboardRowHeight : 0) : 0 visible: enabled && raised property bool shiftMode: false @@ -93,24 +100,35 @@ Item { } Rectangle { - id: leftRect y: 0 - height: 200 + x: 0 + height: showMirrorText ? mirrorTextHeight : 0 + width: keyboardWidth color: "#252525" - anchors.right: keyboardRect.left - anchors.rightMargin: 0 - anchors.bottom: parent.bottom - anchors.bottomMargin: 0 - anchors.left: parent.left - anchors.leftMargin: 0 + + TextEdit { + id: mirrorText + visible: showMirrorText + size: 13.5 + horizontalAlignment: Text.AlignHCenter + color: "#FFFFFF"; + anchors.fill: parent + wrapMode: Text.WordWrap + readOnly: false // we need to leave this property read-only to allow control to accept QKeyEvent + selectByMouse: false + } + + MouseArea { // ... and we need this mouse area to prevent mirrorText from getting mouse events to ensure it will never get focus + anchors.fill: parent + } } Rectangle { id: keyboardRect - x: 206 - y: 0 - width: 480 - height: 200 + x: 0 + y: showMirrorText ? mirrorTextHeight : 0 + width: keyboardWidth + height: raisedHeight color: "#252525" anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.bottom @@ -118,13 +136,13 @@ Item { Column { id: columnAlpha - width: 480 - height: 200 + width: keyboardWidth + height: raisedHeight visible: !numeric Row { - width: 480 - height: 50 + width: keyboardWidth + height: keyboardRowHeight anchors.left: parent.left anchors.leftMargin: 4 @@ -142,8 +160,8 @@ Item { } Row { - width: 480 - height: 50 + width: keyboardWidth + height: keyboardRowHeight anchors.left: parent.left anchors.leftMargin: 20 @@ -160,8 +178,8 @@ Item { } Row { - width: 480 - height: 50 + width: keyboardWidth + height: keyboardRowHeight anchors.left: parent.left anchors.leftMargin: 4 @@ -185,8 +203,8 @@ Item { } Row { - width: 480 - height: 50 + width: keyboardWidth + height: keyboardRowHeight anchors.left: parent.left anchors.leftMargin: 4 @@ -205,13 +223,13 @@ Item { Column { id: columnNumeric - width: 480 - height: 200 + width: keyboardWidth + height: raisedHeight visible: numeric Row { - width: 480 - height: 50 + width: keyboardWidth + height: keyboardRowHeight anchors.left: parent.left anchors.leftMargin: 4 @@ -229,8 +247,8 @@ Item { } Row { - width: 480 - height: 50 + width: keyboardWidth + height: keyboardRowHeight anchors.left: parent.left anchors.leftMargin: 4 @@ -248,8 +266,8 @@ Item { } Row { - width: 480 - height: 50 + width: keyboardWidth + height: keyboardRowHeight anchors.left: parent.left anchors.leftMargin: 4 @@ -273,8 +291,8 @@ Item { } Row { - width: 480 - height: 50 + width: keyboardWidth + height: keyboardRowHeight anchors.left: parent.left anchors.leftMargin: 4 @@ -291,31 +309,4 @@ Item { } } } - - Rectangle { - id: rightRect - y: 280 - height: 200 - color: "#252525" - border.width: 0 - anchors.left: keyboardRect.right - anchors.leftMargin: 0 - anchors.right: parent.right - anchors.rightMargin: 0 - anchors.bottom: parent.bottom - anchors.bottomMargin: 0 - } - - Rectangle { - id: rectangle1 - color: "#ffffff" - anchors.bottom: keyboardRect.top - anchors.bottomMargin: 0 - anchors.left: parent.left - anchors.leftMargin: 0 - anchors.right: parent.right - anchors.rightMargin: 0 - anchors.top: parent.top - anchors.topMargin: 0 - } } diff --git a/libraries/ui/src/ui/OffscreenQmlSurface.cpp b/libraries/ui/src/ui/OffscreenQmlSurface.cpp index d03842d45a..faf7933d1a 100644 --- a/libraries/ui/src/ui/OffscreenQmlSurface.cpp +++ b/libraries/ui/src/ui/OffscreenQmlSurface.cpp @@ -987,8 +987,8 @@ static bool equals(const QByteArray& byteArray, const uint8_t* ptr) { return ptr[i] == 0x00; } -void OffscreenQmlSurface::synthesizeKeyPress(QString key) { - auto eventHandler = getEventHandler(); +void OffscreenQmlSurface::synthesizeKeyPress(QString key, QObject* targetOverride) { + auto eventHandler = targetOverride ? targetOverride : getEventHandler(); if (eventHandler) { auto utf8Key = key.toUtf8(); diff --git a/libraries/ui/src/ui/OffscreenQmlSurface.h b/libraries/ui/src/ui/OffscreenQmlSurface.h index 95dabdef0f..990f81848d 100644 --- a/libraries/ui/src/ui/OffscreenQmlSurface.h +++ b/libraries/ui/src/ui/OffscreenQmlSurface.h @@ -79,7 +79,7 @@ public: bool eventFilter(QObject* originalDestination, QEvent* event) override; void setKeyboardRaised(QObject* object, bool raised, bool numeric = false); - Q_INVOKABLE void synthesizeKeyPress(QString key); + Q_INVOKABLE void synthesizeKeyPress(QString key, QObject* targetOverride = nullptr); using TextureAndFence = std::pair; // Checks to see if a new texture is available. If one is, the function returns true and