keep qml text fields up to date with vive virtual keyboard

This commit is contained in:
howard-stearns 2016-08-02 10:13:35 -07:00
parent f71a59276c
commit 6e7b828203

View file

@ -170,8 +170,7 @@ void showOpenVrKeyboard(bool show = true) {
}
}
void finishOpenVrKeyboardInput() {
auto offscreenUi = DependencyManager::get<OffscreenUi>();
void updateFromOpenVrKeyboardInput() {
auto chars = _overlay->GetKeyboardText(textArray, 8192);
auto newText = QString(QByteArray(textArray, chars));
_keyboardFocusObject->setProperty("text", newText);
@ -181,6 +180,10 @@ void finishOpenVrKeyboardInput() {
//QInputMethodEvent event(_existingText, QList<QInputMethodEvent::Attribute>());
//event.setCommitString(newText, 0, _existingText.size());
//qApp->sendEvent(_keyboardFocusObject, &event);
}
void finishOpenVrKeyboardInput() {
auto offscreenUi = DependencyManager::get<OffscreenUi>();
updateFromOpenVrKeyboardInput();
// Simulate an enter press on the top level window to trigger the action
if (0 == (_currentHints & Qt::ImhMultiLine)) {
qApp->sendEvent(offscreenUi->getWindow(), &QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::KeyboardModifiers(), QString("\n")));
@ -261,6 +264,11 @@ void handleOpenVrEvents() {
QMetaObject::invokeMethod(qApp, "quit");
break;
case vr::VREvent_KeyboardCharInput:
// Make the focused field match the keyboard results, inclusive of combining characters and such.
updateFromOpenVrKeyboardInput();
break;
case vr::VREvent_KeyboardDone:
finishOpenVrKeyboardInput();