Fix placeholder text rendered on top of cursor when empty LineEdit is focused (#1888)

Render the placeholder underneath.
This commit is contained in:
Simon Hausmann 2022-11-22 17:51:41 +01:00 committed by GitHub
parent 2f07caf7d1
commit fd64060b26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 23 deletions

View file

@ -19,6 +19,11 @@ export LineEditInner := Rectangle {
min-width: max(50px, placeholder.min-width);
clip: true;
forward-focus: input;
placeholder := Text {
height: 100%; width: 100%;
vertical-alignment: center;
text: (root.text == "" && input.preedit-text == "") ? root.placeholder-text : "";
}
input := TextInput {
property <length> computed_x;
x: min(0px, max(parent.width - width, computed_x));
@ -37,11 +42,6 @@ export LineEditInner := Rectangle {
vertical-alignment: center;
single-line: true;
}
placeholder := Text {
height: 100%; width: 100%;
vertical-alignment: center;
text: (root.text == "" && input.preedit-text == "") ? root.placeholder-text : "";
}
}
export TextEdit := ScrollView {

View file

@ -35,6 +35,24 @@ export LineEdit := Rectangle {
Rectangle {
clip: true;
placeholder := Text {
width: 100%;
height: 100%;
color: md.sys.color.outline-variant;
font-family: md.sys.typescale.body-large.font;
font-size: md.sys.typescale.body-large.size;
font-weight: md.sys.typescale.body-large.weight;
visible: false;
vertical-alignment: center;
states [
empty when input.text == "" : {
visible: true;
}
]
}
input := TextInput {
property <length> computed_x;
property <length> padding-outer: layout.padding-left + layout.padding-right;
@ -59,23 +77,6 @@ export LineEdit := Rectangle {
}
}
}
placeholder := Text {
width: 100%;
height: 100%;
color: md.sys.color.outline-variant;
font-family: md.sys.typescale.body-large.font;
font-size: md.sys.typescale.body-large.size;
font-weight: md.sys.typescale.body-large.weight;
visible: false;
vertical-alignment: center;
states [
empty when input.text == "" : {
visible: true;
}
]
}
}
}
@ -92,4 +93,4 @@ export LineEdit := Rectangle {
input.color: md.sys.color.primary;
}
]
}
}