fix(@desktop/profile): Enter key doesnt activate button

Added code so that in the backup seed phrase modal all actions can be performed with the enter key.
Also added logic for default focus on the confirm button in the ConfirmationDialog.

fixes#2359
This commit is contained in:
Khushboo Mehta 2021-08-18 18:11:17 +02:00 committed by Iuri Matias
parent 8676533339
commit d4de0c25a4
2 changed files with 22 additions and 0 deletions

View File

@ -13,6 +13,8 @@ ModalPopup {
property int seedWord2Idx: -1; property int seedWord2Idx: -1;
property string validationError: "" property string validationError: ""
focus: visible
onOpened: { onOpened: {
seedWord1Idx = -1; seedWord1Idx = -1;
seedWord2Idx = -1; seedWord2Idx = -1;
@ -143,9 +145,19 @@ ModalPopup {
} }
Item { Item {
id: textInput
visible: seedWord1Idx > -1 || seedWord2Idx > -1 visible: seedWord1Idx > -1 || seedWord2Idx > -1
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
focus: visible
onActiveFocusChanged: {
if (activeFocus)
txtFieldWord.forceActiveFocus(Qt.MouseFocusReason)
}
Keys.onReturnPressed: function(event) {
confirmButton.clicked()
}
StyledText { StyledText {
id: txtChk id: txtChk
//% "Check your seed phrase" //% "Check your seed phrase"
@ -223,6 +235,7 @@ ModalPopup {
footer: StatusButton { footer: StatusButton {
id: confirmButton
text: showWarning ? text: showWarning ?
//% "Okay, continue" //% "Okay, continue"
qsTrId("ok-continue") : qsTrId("ok-continue") :
@ -231,6 +244,10 @@ ModalPopup {
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: Style.current.smallPadding anchors.rightMargin: Style.current.smallPadding
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
focus: !textInput.visible
Keys.onReturnPressed: function(event) {
confirmButton.clicked()
}
onClicked: { onClicked: {
if(showWarning){ if(showWarning){
showWarning = false; showWarning = false;

View File

@ -18,6 +18,7 @@ ModalPopup {
width: 400 width: 400
//% "Confirm your action" //% "Confirm your action"
title: qsTrId("confirm-your-action") title: qsTrId("confirm-your-action")
focus: visible
//% "Confirm" //% "Confirm"
property string confirmButtonLabel: qsTrId("close-app-button") property string confirmButtonLabel: qsTrId("close-app-button")
@ -71,6 +72,10 @@ ModalPopup {
anchors.rightMargin: cancelButton.visible ? Style.current.smallPadding : 0 anchors.rightMargin: cancelButton.visible ? Style.current.smallPadding : 0
text: confirmationDialog.confirmButtonLabel text: confirmationDialog.confirmButtonLabel
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
focus: true
Keys.onReturnPressed: function(event) {
confirmButton.clicked()
}
onClicked: { onClicked: {
if (executeConfirm && typeof executeConfirm === "function") { if (executeConfirm && typeof executeConfirm === "function") {
executeConfirm() executeConfirm()