diff --git a/src/StatusQ/Controls/StatusBaseInput.qml b/src/StatusQ/Controls/StatusBaseInput.qml index 1dced1c6..1deec179 100644 --- a/src/StatusQ/Controls/StatusBaseInput.qml +++ b/src/StatusQ/Controls/StatusBaseInput.qml @@ -41,6 +41,7 @@ Item { property real rightPadding: 16 property real topPadding: 12 property real bottomPadding: 12 + property var tabNavItem: null property real minimumHeight: 0 property real maximumHeight: 0 @@ -72,6 +73,8 @@ Item { property Component rightComponent signal iconClicked + signal keyPressed(var event) + signal editClicked() implicitWidth: 448 implicitHeight: multiline ? Math.min(Math.max( @@ -115,8 +118,8 @@ Item { cursorShape: Qt.IBeamCursor onClicked: { edit.forceActiveFocus() + root.editClicked() } - RowLayout { anchors { fill: parent @@ -186,7 +189,12 @@ Item { Keys.onReturnPressed: event.accepted = !multiline Keys.onEnterPressed: event.accepted = !multiline Keys.forwardTo: [root] - Keys.onPressed: edit.keyEvent = event.key + KeyNavigation.priority: !!root.tabNavItem ? KeyNavigation.BeforeItem : KeyNavigation.AfterItem + KeyNavigation.tab: root.tabNavItem + Keys.onPressed: { + edit.keyEvent = event.key + root.keyPressed(event); + } onCursorRectangleChanged: flick.ensureVisible(cursorRectangle) onActiveFocusChanged: if (root.pristine) root.pristine = false diff --git a/src/StatusQ/Controls/StatusInput.qml b/src/StatusQ/Controls/StatusInput.qml index c5d2a913..7b2cdfff 100644 --- a/src/StatusQ/Controls/StatusInput.qml +++ b/src/StatusQ/Controls/StatusInput.qml @@ -107,6 +107,8 @@ Item { property var pendingValidators: [] signal iconClicked() + signal keyPressed(var event) + signal editClicked() /*! \qmltype ValidationMode @@ -290,6 +292,12 @@ Item { Keys.forwardTo: [root] onIconClicked: root.iconClicked() + onKeyPressed: { + root.keyPressed(event); + } + onEditChanged: { + root.editClicked(); + } } StatusBaseText { diff --git a/src/StatusQ/Controls/StatusSeedPhraseInput.qml b/src/StatusQ/Controls/StatusSeedPhraseInput.qml index 7d59a798..90059962 100644 --- a/src/StatusQ/Controls/StatusSeedPhraseInput.qml +++ b/src/StatusQ/Controls/StatusSeedPhraseInput.qml @@ -7,6 +7,42 @@ import StatusQ.Popups 0.1 import StatusQ.Core 0.1 import StatusQ.Core.Theme 0.1 +/*! + \qmltype StatusSeedPhraseInput + \inherits Item + \inqmlmodule StatusQ.Controls + \since StatusQ.Controls 0.1 + \brief Displays a text input with suggestions. Inherits \l{https://doc.qt.io/qt-5/qml-qtquick-item.html}{Item}. + + The \c StatusSeedPhraseInput item displays a text input with suggestions filtered based on the typed text. + For example: + + \qml + StatusSeedPhraseInput { + id: statusSeedInput + anchors.left: parent.left + anchors.right: parent.right + textEdit.input.anchors.leftMargin: 16 + textEdit.input.anchors.rightMargin: 16 + textEdit.input.anchors.topMargin: 11 + leftComponentText: "1" + inputList: ListModel { + ListElement { + seedWord: "panda" + } + ListElement { + seedWord: "posible" + } + ListElement { + seedWord: "wing" + } + } + } + \endqml + + For a list of components available see StatusQ. +*/ + Item { id: root width: 162 @@ -17,6 +53,12 @@ Item { property ListModel inputList: ListModel { } property ListModel filteredList: ListModel { } signal doneInsertingWord(string word) + /* + This signal is emitted when the user pressed a keyboard key and passes as a + parameter the event. The corresponding handler is \c onKeyPressed. + */ + signal keyPressed(var event) + signal editClicked() onActiveFocusChanged: { if (root.activeFocus) { @@ -57,6 +99,12 @@ Item { seedSuggestionsList.model = 0; } } + onKeyPressed: { + root.keyPressed(event); + } + onEditClicked: { + root.editClicked(); + } } Item {