NTextInput: simplified code in an attempt to fix text selection issues with mouse.
Not fixed yet, but I know where the conflict is!
This commit is contained in:
parent
56fedcf495
commit
3140039ccb
5 changed files with 81 additions and 92 deletions
|
|
@ -11,7 +11,6 @@ ColumnLayout {
|
|||
property string description: ""
|
||||
property bool readOnly: false
|
||||
property bool enabled: true
|
||||
property int inputMaxWidth: Math.round(420 * scaling)
|
||||
property color labelColor: Color.mOnSurface
|
||||
property color descriptionColor: Color.mOnSurfaceVariant
|
||||
property string fontFamily: Settings.data.ui.fontDefault
|
||||
|
|
@ -26,7 +25,6 @@ ColumnLayout {
|
|||
signal editingFinished
|
||||
|
||||
spacing: Style.marginS * scaling
|
||||
implicitHeight: frame.height
|
||||
|
||||
NLabel {
|
||||
label: root.label
|
||||
|
|
@ -34,6 +32,7 @@ ColumnLayout {
|
|||
labelColor: root.labelColor
|
||||
descriptionColor: root.descriptionColor
|
||||
visible: root.label !== "" || root.description !== ""
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
// Container
|
||||
|
|
@ -42,50 +41,48 @@ ColumnLayout {
|
|||
|
||||
Layout.fillWidth: true
|
||||
Layout.minimumWidth: 80 * scaling
|
||||
Layout.maximumWidth: root.inputMaxWidth
|
||||
|
||||
implicitWidth: parent.width
|
||||
implicitHeight: Style.baseWidgetSize * 1.1 * scaling
|
||||
|
||||
radius: Style.radiusM * scaling
|
||||
color: Color.mSurface
|
||||
border.color: Color.mOutline
|
||||
border.color: input.activeFocus ? Color.mSecondary : Color.mOutline
|
||||
border.width: Math.max(1, Style.borderS * scaling)
|
||||
|
||||
// Focus ring
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: frame.radius
|
||||
color: Color.transparent
|
||||
border.color: input.activeFocus ? Color.mSecondary : Color.transparent
|
||||
border.width: input.activeFocus ? Math.max(1, Style.borderS * scaling) : 0
|
||||
|
||||
Behavior on border.color {
|
||||
ColorAnimation {
|
||||
duration: Style.animationFast
|
||||
}
|
||||
Behavior on border.color {
|
||||
ColorAnimation {
|
||||
duration: Style.animationFast
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
TextField {
|
||||
id: input
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: Style.marginM * scaling
|
||||
anchors.rightMargin: Style.marginM * scaling
|
||||
spacing: Style.marginS * scaling
|
||||
|
||||
TextField {
|
||||
id: input
|
||||
Layout.fillWidth: true
|
||||
echoMode: TextInput.Normal
|
||||
readOnly: root.readOnly
|
||||
enabled: root.enabled
|
||||
color: Color.mOnSurface
|
||||
placeholderTextColor: Qt.alpha(Color.mOnSurfaceVariant, 0.6)
|
||||
background: null
|
||||
font.family: fontFamily
|
||||
font.pointSize: fontSize
|
||||
font.weight: fontWeight
|
||||
onEditingFinished: root.editingFinished()
|
||||
}
|
||||
verticalAlignment: TextInput.AlignVCenter
|
||||
|
||||
echoMode: TextInput.Normal
|
||||
readOnly: root.readOnly
|
||||
enabled: root.enabled
|
||||
color: Color.mOnSurface
|
||||
placeholderTextColor: Qt.alpha(Color.mOnSurfaceVariant, 0.6)
|
||||
|
||||
selectByMouse: true
|
||||
|
||||
topPadding: 0
|
||||
bottomPadding: 0
|
||||
leftPadding: 0
|
||||
rightPadding: 0
|
||||
|
||||
background: null
|
||||
|
||||
font.family: root.fontFamily
|
||||
font.pointSize: root.fontSize
|
||||
font.weight: root.fontWeight
|
||||
|
||||
onEditingFinished: root.editingFinished()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue