Index: sources/gui/qml/components/TextEntry.qml =================================================================== diff -u -r6c5b5292ae3b3ebf979175dcb1256c88b1baf90c -r559dc64d12cf7647ec8c29ccbf4ca90f90e5e3a2 --- sources/gui/qml/components/TextEntry.qml (.../TextEntry.qml) (revision 6c5b5292ae3b3ebf979175dcb1256c88b1baf90c) +++ sources/gui/qml/components/TextEntry.qml (.../TextEntry.qml) (revision 559dc64d12cf7647ec8c29ccbf4ca90f90e5e3a2) @@ -1,15 +1,15 @@ /*! * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * - * \file TextEntry.qml - * \author (last) Peter Lucia - * \date (last) 07-Jan-2021 - * \author (original) Peter Lucia - * \date (original) 07-Jan-2021 + * \file TextEntry.qml + * \author (last) Behrouz NematiPour + * \date (last) 02-Apr-2023 + * \author (original) Behrouz NematiPour + * \date (original) 16-Apr-2021 * */ @@ -30,13 +30,16 @@ property alias textInput : _input property alias line : _line property alias label : _label + property alias separator : _separator property alias validator : _input.validator property var nextInput : undefined property alias text : _input.text + property bool hasCursor : true readonly property alias isValid : _input.acceptableInput - signal enterPressed() + signal enterPressed () + signal clicked (var vMouse) width : _label.width + _input.width height : TextEntry.EntryHeight @@ -49,6 +52,15 @@ } } + function doFocus( vFocus ) { + if ( vFocus ) { + if ( ! _root.hasCursor ) { + _input.selectAll() + } + _keyboard.setVisible(true) + } + } + Text { id : _label height : parent.height anchors.left : parent.left @@ -57,33 +69,53 @@ font.pixelSize : Fonts.fontPixelTextRectExtra } + Text { id : _separator + visible : text + width : 0 + text : "" + height : parent.height + anchors.left : _label.right + anchors.top : parent.top + color : Colors.textMain + font.pixelSize : Fonts.fontPixelTextRectExtra + horizontalAlignment: Text.AlignLeft + } + TextInput { id : _input + enabled : hasCursor height : parent.height width : TextEntry.InputWidth text : "" font.pixelSize : Fonts.fontPixelTextRectExtra color : acceptableInput ? Colors.textMain : Colors.red selectionColor : Colors.borderButtonHalfDarker selectedTextColor : acceptableInput ? Colors.textMain : Colors.red - anchors.left : _label.right + anchors.left : _separator.right horizontalAlignment : TextInput.AlignHCenter inputMethodHints : Qt.ImhDigitsOnly selectByMouse : true activeFocusOnPress : true onAccepted : _root.enterPressed() - onFocusChanged : { - if (focus) { - selectAll() - _keyboard.setVisible(true) - } - } + onFocusChanged : doFocus(focus) } Line { id : _line + visible : hasCursor color : Colors.borderButtonHalfDarker width : _input.width anchors.top : _input.bottom anchors.left: _input.left anchors.topMargin : -thickness // move it up to be in the container rect in case the TextEntry clip set true. } + + MouseArea { + visible : ! hasCursor + anchors.fill: parent + propagateComposedEvents: true + onClicked: { + _input.forceActiveFocus() + doFocus(true) + _root.clicked(mouse) + } + } }