mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 17:41:12 +02:00
property set echomode for keyboard for wallet and webviews
This commit is contained in:
parent
0242e8e4ba
commit
92f765fe52
9 changed files with 56 additions and 17 deletions
|
@ -14,6 +14,12 @@
|
||||||
var isWindowFocused = true;
|
var isWindowFocused = true;
|
||||||
var isKeyboardRaised = false;
|
var isKeyboardRaised = false;
|
||||||
var isNumericKeyboard = false;
|
var isNumericKeyboard = false;
|
||||||
|
var isPasswordField = false;
|
||||||
|
|
||||||
|
function shouldSetPasswordField() {
|
||||||
|
var nodeType = document.activeElement.type;
|
||||||
|
return nodeType === "password";
|
||||||
|
}
|
||||||
|
|
||||||
function shouldRaiseKeyboard() {
|
function shouldRaiseKeyboard() {
|
||||||
var nodeName = document.activeElement.nodeName;
|
var nodeName = document.activeElement.nodeName;
|
||||||
|
@ -53,12 +59,14 @@
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
var keyboardRaised = shouldRaiseKeyboard();
|
var keyboardRaised = shouldRaiseKeyboard();
|
||||||
var numericKeyboard = shouldSetNumeric();
|
var numericKeyboard = shouldSetNumeric();
|
||||||
|
var passwordField = shouldSetPasswordField();
|
||||||
|
|
||||||
if (isWindowFocused && (keyboardRaised !== isKeyboardRaised || numericKeyboard !== isNumericKeyboard)) {
|
if (isWindowFocused &&
|
||||||
|
(keyboardRaised !== isKeyboardRaised || numericKeyboard !== isNumericKeyboard || passwordField !== isPasswordField)) {
|
||||||
|
|
||||||
if (typeof EventBridge !== "undefined" && EventBridge !== null) {
|
if (typeof EventBridge !== "undefined" && EventBridge !== null) {
|
||||||
EventBridge.emitWebEvent(
|
EventBridge.emitWebEvent(
|
||||||
keyboardRaised ? ("_RAISE_KEYBOARD" + (numericKeyboard ? "_NUMERIC" : "")) : "_LOWER_KEYBOARD"
|
keyboardRaised ? ("_RAISE_KEYBOARD" + (numericKeyboard ? "_NUMERIC" : "") + (passwordField ? "_PASSWORD" : "")) : "_LOWER_KEYBOARD"
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (numWarnings < MAX_WARNINGS) {
|
if (numWarnings < MAX_WARNINGS) {
|
||||||
|
@ -74,6 +82,7 @@
|
||||||
|
|
||||||
isKeyboardRaised = keyboardRaised;
|
isKeyboardRaised = keyboardRaised;
|
||||||
isNumericKeyboard = numericKeyboard;
|
isNumericKeyboard = numericKeyboard;
|
||||||
|
isPasswordField = passwordField;
|
||||||
}
|
}
|
||||||
}, POLL_FREQUENCY);
|
}, POLL_FREQUENCY);
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,6 @@ Item {
|
||||||
onLinkActivated: loginDialog.openUrl(link)
|
onLinkActivated: loginDialog.openUrl(link)
|
||||||
}
|
}
|
||||||
onFocusChanged: {
|
onFocusChanged: {
|
||||||
console.log("-------> setting variable <-------");
|
|
||||||
root.text = "";
|
root.text = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ Item {
|
||||||
property bool keyboardEnabled: false
|
property bool keyboardEnabled: false
|
||||||
property bool keyboardRaised: false
|
property bool keyboardRaised: false
|
||||||
property bool punctuationMode: false
|
property bool punctuationMode: false
|
||||||
|
property bool passwordField: false
|
||||||
property bool isDesktop: false
|
property bool isDesktop: false
|
||||||
property alias webView: web.webViewCore
|
property alias webView: web.webViewCore
|
||||||
property alias profile: web.webViewCoreProfile
|
property alias profile: web.webViewCoreProfile
|
||||||
|
@ -41,7 +42,7 @@ Item {
|
||||||
horizontalCenter: parent.horizontalCenter
|
horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
spacing: 120
|
spacing: 120
|
||||||
|
|
||||||
TabletWebButton {
|
TabletWebButton {
|
||||||
id: back
|
id: back
|
||||||
enabledColor: hifi.colors.darkGray
|
enabledColor: hifi.colors.darkGray
|
||||||
|
@ -165,6 +166,11 @@ Item {
|
||||||
id: keyboard
|
id: keyboard
|
||||||
raised: parent.keyboardEnabled && parent.keyboardRaised
|
raised: parent.keyboardEnabled && parent.keyboardRaised
|
||||||
numeric: parent.punctuationMode
|
numeric: parent.punctuationMode
|
||||||
|
password: parent.passwordField
|
||||||
|
|
||||||
|
onPasswordChanged: {
|
||||||
|
keyboard.mirroredText = "";
|
||||||
|
}
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
|
@ -172,7 +178,7 @@ Item {
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
root.isDesktop = (typeof desktop !== "undefined");
|
root.isDesktop = (typeof desktop !== "undefined");
|
||||||
keyboardEnabled = HMD.active;
|
keyboardEnabled = HMD.active;
|
||||||
|
|
|
@ -13,6 +13,7 @@ Item {
|
||||||
property bool keyboardEnabled: true // FIXME - Keyboard HMD only: Default to false
|
property bool keyboardEnabled: true // FIXME - Keyboard HMD only: Default to false
|
||||||
property bool keyboardRaised: false
|
property bool keyboardRaised: false
|
||||||
property bool punctuationMode: false
|
property bool punctuationMode: false
|
||||||
|
property bool passwordField: false
|
||||||
property alias flickable: webroot.interactive
|
property alias flickable: webroot.interactive
|
||||||
|
|
||||||
// FIXME - Keyboard HMD only: Make Interface either set keyboardRaised property directly in OffscreenQmlSurface
|
// FIXME - Keyboard HMD only: Make Interface either set keyboardRaised property directly in OffscreenQmlSurface
|
||||||
|
@ -50,6 +51,7 @@ Item {
|
||||||
id: keyboard
|
id: keyboard
|
||||||
raised: parent.keyboardEnabled && parent.keyboardRaised
|
raised: parent.keyboardEnabled && parent.keyboardRaised
|
||||||
numeric: parent.punctuationMode
|
numeric: parent.punctuationMode
|
||||||
|
password: parent.passwordField
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
right: parent.right
|
right: parent.right
|
||||||
|
|
|
@ -27,6 +27,7 @@ Item {
|
||||||
id: root;
|
id: root;
|
||||||
z: 997;
|
z: 997;
|
||||||
property bool keyboardRaised: false;
|
property bool keyboardRaised: false;
|
||||||
|
property bool isPasswordField: false;
|
||||||
property string titleBarIcon: "";
|
property string titleBarIcon: "";
|
||||||
property string titleBarText: "";
|
property string titleBarText: "";
|
||||||
|
|
||||||
|
@ -202,6 +203,7 @@ Item {
|
||||||
|
|
||||||
onFocusChanged: {
|
onFocusChanged: {
|
||||||
root.keyboardRaised = focus;
|
root.keyboardRaised = focus;
|
||||||
|
root.isPasswordField = (focus && passphraseField.echoMode === TextInput.Password);
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
@ -209,6 +211,7 @@ Item {
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.keyboardRaised = true;
|
root.keyboardRaised = true;
|
||||||
|
root.isPasswordField = (passphraseField.echoMode === TextInput.Password);
|
||||||
mouse.accepted = false;
|
mouse.accepted = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -382,6 +385,7 @@ Item {
|
||||||
id: keyboard;
|
id: keyboard;
|
||||||
raised: HMD.mounted && root.keyboardRaised;
|
raised: HMD.mounted && root.keyboardRaised;
|
||||||
numeric: parent.punctuationMode;
|
numeric: parent.punctuationMode;
|
||||||
|
password: root.isPasswordField;
|
||||||
anchors {
|
anchors {
|
||||||
bottom: parent.bottom;
|
bottom: parent.bottom;
|
||||||
left: parent.left;
|
left: parent.left;
|
||||||
|
|
|
@ -80,16 +80,18 @@ Item {
|
||||||
|
|
||||||
onFocusChanged: {
|
onFocusChanged: {
|
||||||
if (focus) {
|
if (focus) {
|
||||||
sendSignalToWallet({method: 'walletSetup_raiseKeyboard'});
|
var hidePassword = (currentPassphraseField.echoMode === TextInput.Password);
|
||||||
|
sendSignalToWallet({method: 'walletSetup_raiseKeyboard', isPasswordField: hidePassword});
|
||||||
} else if (!passphraseFieldAgain.focus) {
|
} else if (!passphraseFieldAgain.focus) {
|
||||||
sendSignalToWallet({method: 'walletSetup_lowerKeyboard'});
|
sendSignalToWallet({method: 'walletSetup_lowerKeyboard', isPasswordField: false});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
onPressed: {
|
onPressed: {
|
||||||
sendSignalToWallet({method: 'walletSetup_raiseKeyboard'});
|
var hidePassword = (currentPassphraseField.echoMode === TextInput.Password);
|
||||||
|
sendSignalToWallet({method: 'walletSetup_raiseKeyboard', isPasswordField: hidePassword});
|
||||||
mouse.accepted = false;
|
mouse.accepted = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,16 +118,18 @@ Item {
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
onPressed: {
|
onPressed: {
|
||||||
sendSignalToWallet({method: 'walletSetup_raiseKeyboard'});
|
var hidePassword = (passphraseField.echoMode === TextInput.Password);
|
||||||
|
sendSignalToWallet({method: 'walletSetup_raiseKeyboard', isPasswordField: hidePassword});
|
||||||
mouse.accepted = false;
|
mouse.accepted = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onFocusChanged: {
|
onFocusChanged: {
|
||||||
if (focus) {
|
if (focus) {
|
||||||
sendMessageToLightbox({method: 'walletSetup_raiseKeyboard'});
|
var hidePassword = (passphraseField.echoMode === TextInput.Password);
|
||||||
|
sendMessageToLightbox({method: 'walletSetup_raiseKeyboard', isPasswordField: hidePassword});
|
||||||
} else if (!passphraseFieldAgain.focus) {
|
} else if (!passphraseFieldAgain.focus) {
|
||||||
sendMessageToLightbox({method: 'walletSetup_lowerKeyboard'});
|
sendMessageToLightbox({method: 'walletSetup_lowerKeyboard', isPasswordField: false});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,16 +154,18 @@ Item {
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
onPressed: {
|
onPressed: {
|
||||||
sendSignalToWallet({method: 'walletSetup_raiseKeyboard'});
|
var hidePassword = (passphraseFieldAgain.echoMode === TextInput.Password);
|
||||||
|
sendSignalToWallet({method: 'walletSetup_raiseKeyboard', isPasswordField: hidePassword});
|
||||||
mouse.accepted = false;
|
mouse.accepted = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onFocusChanged: {
|
onFocusChanged: {
|
||||||
if (focus) {
|
if (focus) {
|
||||||
sendMessageToLightbox({method: 'walletSetup_raiseKeyboard'});
|
var hidePassword = (passphraseFieldAgain.echoMode === TextInput.Password);
|
||||||
|
sendMessageToLightbox({method: 'walletSetup_raiseKeyboard', isPasswordField: hidePassword});
|
||||||
} else if (!passphraseField.focus) {
|
} else if (!passphraseField.focus) {
|
||||||
sendMessageToLightbox({method: 'walletSetup_lowerKeyboard'});
|
sendMessageToLightbox({method: 'walletSetup_lowerKeyboard', isPasswordField: false});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ Rectangle {
|
||||||
|
|
||||||
property string activeView: "initialize";
|
property string activeView: "initialize";
|
||||||
property bool keyboardRaised: false;
|
property bool keyboardRaised: false;
|
||||||
|
property bool isPassword: false;
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
|
@ -181,8 +182,10 @@ Rectangle {
|
||||||
}
|
}
|
||||||
} else if (msg.method === 'walletSetup_raiseKeyboard') {
|
} else if (msg.method === 'walletSetup_raiseKeyboard') {
|
||||||
root.keyboardRaised = true;
|
root.keyboardRaised = true;
|
||||||
|
root.isPassword = msg.isPasswordField;
|
||||||
} else if (msg.method === 'walletSetup_lowerKeyboard') {
|
} else if (msg.method === 'walletSetup_lowerKeyboard') {
|
||||||
root.keyboardRaised = false;
|
root.keyboardRaised = false;
|
||||||
|
root.isPassword = msg.isPasswordField;
|
||||||
} else {
|
} else {
|
||||||
sendToScript(msg);
|
sendToScript(msg);
|
||||||
}
|
}
|
||||||
|
@ -202,6 +205,7 @@ Rectangle {
|
||||||
onSendSignalToWallet: {
|
onSendSignalToWallet: {
|
||||||
if (msg.method === 'walletSetup_raiseKeyboard') {
|
if (msg.method === 'walletSetup_raiseKeyboard') {
|
||||||
root.keyboardRaised = true;
|
root.keyboardRaised = true;
|
||||||
|
root.isPassword = msg.isPasswordField;
|
||||||
} else if (msg.method === 'walletSetup_lowerKeyboard') {
|
} else if (msg.method === 'walletSetup_lowerKeyboard') {
|
||||||
root.keyboardRaised = false;
|
root.keyboardRaised = false;
|
||||||
} else if (msg.method === 'walletSecurity_changePassphraseCancelled') {
|
} else if (msg.method === 'walletSecurity_changePassphraseCancelled') {
|
||||||
|
@ -685,6 +689,7 @@ Rectangle {
|
||||||
id: keyboard;
|
id: keyboard;
|
||||||
raised: HMD.mounted && root.keyboardRaised;
|
raised: HMD.mounted && root.keyboardRaised;
|
||||||
numeric: parent.punctuationMode;
|
numeric: parent.punctuationMode;
|
||||||
|
password: root.isPassword;
|
||||||
anchors {
|
anchors {
|
||||||
bottom: parent.bottom;
|
bottom: parent.bottom;
|
||||||
left: parent.left;
|
left: parent.left;
|
||||||
|
|
|
@ -1082,7 +1082,7 @@ void OffscreenQmlSurface::synthesizeKeyPress(QString key, QObject* targetOverrid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::setKeyboardRaised(QObject* object, bool raised, bool numeric) {
|
void OffscreenQmlSurface::setKeyboardRaised(QObject* object, bool raised, bool numeric, bool passwordField) {
|
||||||
#if Q_OS_ANDROID
|
#if Q_OS_ANDROID
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1113,6 +1113,10 @@ void OffscreenQmlSurface::setKeyboardRaised(QObject* object, bool raised, bool n
|
||||||
if (item->property("punctuationMode").isValid()) {
|
if (item->property("punctuationMode").isValid()) {
|
||||||
item->setProperty("punctuationMode", QVariant(numeric));
|
item->setProperty("punctuationMode", QVariant(numeric));
|
||||||
}
|
}
|
||||||
|
if (item->property("passwordField").isValid()) {
|
||||||
|
item->setProperty("passwordField", QVariant(passwordField));
|
||||||
|
}
|
||||||
|
|
||||||
item->setProperty("keyboardRaised", QVariant(raised));
|
item->setProperty("keyboardRaised", QVariant(raised));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1137,9 +1141,13 @@ void OffscreenQmlSurface::emitWebEvent(const QVariant& message) {
|
||||||
const QString RAISE_KEYBOARD = "_RAISE_KEYBOARD";
|
const QString RAISE_KEYBOARD = "_RAISE_KEYBOARD";
|
||||||
const QString RAISE_KEYBOARD_NUMERIC = "_RAISE_KEYBOARD_NUMERIC";
|
const QString RAISE_KEYBOARD_NUMERIC = "_RAISE_KEYBOARD_NUMERIC";
|
||||||
const QString LOWER_KEYBOARD = "_LOWER_KEYBOARD";
|
const QString LOWER_KEYBOARD = "_LOWER_KEYBOARD";
|
||||||
|
const QString RAISE_KEYBOARD_NUMERIC_PASSWORD = "_RAISE_KEYBOARD_NUMERIC_PASSWORD";
|
||||||
|
const QString RAISE_KEYBOARD_PASSWORD = "_RAISE_KEYBOARD_PASSWORD";
|
||||||
QString messageString = message.type() == QVariant::String ? message.toString() : "";
|
QString messageString = message.type() == QVariant::String ? message.toString() : "";
|
||||||
if (messageString.left(RAISE_KEYBOARD.length()) == RAISE_KEYBOARD) {
|
if (messageString.left(RAISE_KEYBOARD.length()) == RAISE_KEYBOARD) {
|
||||||
setKeyboardRaised(_currentFocusItem, true, messageString == RAISE_KEYBOARD_NUMERIC);
|
bool numeric = (messageString == RAISE_KEYBOARD_NUMERIC || messageString == RAISE_KEYBOARD_NUMERIC_PASSWORD);
|
||||||
|
bool passwordField = (messageString == RAISE_KEYBOARD_PASSWORD || messageString == RAISE_KEYBOARD_NUMERIC_PASSWORD);
|
||||||
|
setKeyboardRaised(_currentFocusItem, true, numeric, passwordField);
|
||||||
} else if (messageString == LOWER_KEYBOARD) {
|
} else if (messageString == LOWER_KEYBOARD) {
|
||||||
setKeyboardRaised(_currentFocusItem, false);
|
setKeyboardRaised(_currentFocusItem, false);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -82,7 +82,7 @@ public:
|
||||||
QPointF mapToVirtualScreen(const QPointF& originalPoint, QObject* originalWidget);
|
QPointF mapToVirtualScreen(const QPointF& originalPoint, QObject* originalWidget);
|
||||||
bool eventFilter(QObject* originalDestination, QEvent* event) override;
|
bool eventFilter(QObject* originalDestination, QEvent* event) override;
|
||||||
|
|
||||||
void setKeyboardRaised(QObject* object, bool raised, bool numeric = false);
|
void setKeyboardRaised(QObject* object, bool raised, bool numeric = false, bool passwordField = false);
|
||||||
Q_INVOKABLE void synthesizeKeyPress(QString key, QObject* targetOverride = nullptr);
|
Q_INVOKABLE void synthesizeKeyPress(QString key, QObject* targetOverride = nullptr);
|
||||||
|
|
||||||
using TextureAndFence = std::pair<uint32_t, void*>;
|
using TextureAndFence = std::pair<uint32_t, void*>;
|
||||||
|
|
Loading…
Reference in a new issue