Index: sources/gui/qml/components/TextEntry.qml =================================================================== diff -u -r840b91f4f72d599bb523050dda2183a6611017b5 -r559dc64d12cf7647ec8c29ccbf4ca90f90e5e3a2 --- sources/gui/qml/components/TextEntry.qml (.../TextEntry.qml) (revision 840b91f4f72d599bb523050dda2183a6611017b5) +++ 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 * */ @@ -22,24 +22,28 @@ Item { id: _root enum Constants { - TextInputWidth = 350 , - TextInputHeight = 50 , - TextInputLineWidth = 100 + EntryWidth = 350 , + EntryHeight = 40 , + InputWidth = 100 } - property alias textInput : _input - property alias line : _line - property alias label : _label - property alias labelText : _label.text - property alias validator : _input.validator - property alias labelVisible : _label.visible - property var nextInput : undefined + 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 - signal enterPressed() + readonly property alias isValid : _input.acceptableInput - width : TextEntry.TextInputWidth - height : TextEntry.TextInputHeight + signal enterPressed () + signal clicked (var vMouse) + width : _label.width + _input.width + height : TextEntry.EntryHeight + onEnterPressed : { if (nextInput) { if (textInput.acceptableInput) { @@ -48,48 +52,70 @@ } } - Text { id: _label - anchors { - left: parent.left - top: parent.top + function doFocus( vFocus ) { + if ( vFocus ) { + if ( ! _root.hasCursor ) { + _input.selectAll() + } + _keyboard.setVisible(true) } - color: Colors.textMain - font.pixelSize: Fonts.fontPixelTextRectExtra } - TextInput { id: _input - anchors { - left: _label.right - } + Text { id : _label + height : parent.height + anchors.left : parent.left + anchors.top : parent.top + color : Colors.textMain + font.pixelSize : Fonts.fontPixelTextRectExtra + } - color: acceptableInput ? Colors.textMain : Colors.red - text: "" - font.pixelSize: Fonts.fontPixelTextRectExtra - selectionColor: Colors.borderButtonHalfDarker - height: parent.height - width: TextEntry.TextInputLineWidth - horizontalAlignment: TextInput.AlignHCenter - inputMethodHints: Qt.ImhDigitsOnly - selectedTextColor: acceptableInput ? Colors.textMain : Colors.red - selectByMouse: true - activeFocusOnPress: true - onFocusChanged: { - if (focus) { - selectAll() - _keyboard.setVisible(true) - } - } - onAccepted: { - _root.enterPressed() - } + 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 } - Line { id: _line - color: Colors.borderButtonHalfDarker - width: TextEntry.TextInputLineWidth - anchors { - top: _input.bottom - left: _input.left + 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 : _separator.right + horizontalAlignment : TextInput.AlignHCenter + inputMethodHints : Qt.ImhDigitsOnly + selectByMouse : true + activeFocusOnPress : true + onAccepted : _root.enterPressed() + 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) } } }