mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 02:39:28 +00:00
Fix placeholder text rendered on top of cursor when empty LineEdit is focused (#1888)
Render the placeholder underneath.
This commit is contained in:
parent
2f07caf7d1
commit
fd64060b26
2 changed files with 24 additions and 23 deletions
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue