Skip to content

Commit

Permalink
Fix suffix alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasMizera committed Apr 17, 2024
1 parent 24c048d commit 08fd6a5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions app/qml/form/editors/MMFormNumberEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,24 @@ MMPrivateComponents.MMBaseSingleLineInput {
text: root._fieldValue === undefined || root._fieldValueIsNull ? '' : root._fieldValue

clip: true
horizontalAlignment: Qt.AlignHCenter

// AlignHCenter with optional suffix
leftPadding: Math.max( 0, ( textField.width / 2 - textField.contentWidth / 2 ) - ( internal.suffix ? suffixText.width / 2 : 0 ) )

inputMethodHints: Qt.ImhFormattedNumbersOnly

background: Rectangle {
color: "transparent"

// add suffix
Text {
anchors.centerIn: parent
anchors.horizontalCenterOffset: textField.contentWidth / 2 + __style.margin10
// Suffix is added as a part of the background property in order to not block clicks to the textField
MMComponents.MMText {
id: suffixText

property real maxWidth: textField.width / 2

width: Math.min( implicitWidth + __style.margin4, maxWidth )
x: textField.leftPadding + textField.contentWidth + __style.margin4
anchors.verticalCenter: parent.verticalCenter

color: __style.nightColor
font: __style.p5
Expand Down

0 comments on commit 08fd6a5

Please sign in to comment.