text Input height ? #8898
-
i cannot get how to use textInput ? fist i've skipp TextEdit because i cannot customize it as i want i want my textinput in a rectangle (color and rouded corners) what i expect
i've try a lot of things but the TextInput behavior looks very in-intuitive export component testText inherits Rectangle {
in-out property <string> text : "abcdefghijklmnopqrstuvwxyzabcdefghijklmn";
in-out property <length> font-size : 14px;
property <int> size;
background: blue;
border-radius: 30px;
min-height: font-size*2.5;
VerticalLayout {
padding: parent.border-radius/2;
ScrollView {
vertical-scrollbar-policy: always-on;
Rectangle {
background: green;
}
property <int> hg : 20;
TextInput {
vertical-alignment: center;
height: 20px;
page-height: 20px;
font-size: 15px;
single-line: false;
text: text;
edited => {
text = self.text;
hg = self.height/1px;
}
}
Text {
text: hg;
x:0px;
y:50px;
}
}
}
Text {
text: parent.width/1px;
x: 5px;
y: 5px;
} |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 4 replies
-
Does setting the |
Beta Was this translation helpful? Give feedback.
-
Is it better if you split the components (like actually something like component MyTextEdit inherits Rectangle {
padding <=> layout.padding; // NOTE: link the (non-functional) padding prop to the layout (a rectangle is not a layout)
layout := HorizontalLayout {
TextInput { … }
}
}
export component TheBiggerPicture {
layout := VerticalLayout {
MyTextEdit {
background: blue;
padding: 17px;
}
}
} |
Beta Was this translation helpful? Give feedback.
-
So nobody know how to do this ? because if we cannot manage line-wrap and text input height, this shoud definitly make this as an issue |
Beta Was this translation helpful? Give feedback.
-
Is this what you are aiming for? import { AboutSlint, Button, VerticalBox, ScrollView, StyleMetrics } from "std-widgets.slint";
component MyTextInput inherits Rectangle {
background: blue;
padding <=> layout.padding;
out property text <=> text.text;
in property placeholder-text <=> text.accessible-placeholder-text;
ScrollView {
layout := HorizontalLayout {
padding: StyleMetrics.layout-padding;
text := TextInput {
vertical-alignment: center;
font-size: 15px;
single-line: false;
wrap: word-wrap;
}
}
}
}
export component testText {
in-out property <string> text: "abcdefghijklmnopqrstuvwxyzabcdefghijklmn";
in-out property <length> font-size: 14px;
property <int> size;
VerticalLayout {
Rectangle {
background: red;
vertical-stretch: 1;
}
HorizontalLayout {
MyTextInput {
horizontal-stretch: 1;
}
Button {
text: "send";
}
}
}
} |
Beta Was this translation helpful? Give feedback.
-
It works partially without the scroll view, of course, you can't scroll. except that with the scroll view, it completely breaks the height calculation in the parent layout export component SendButton {
callback clicked();
Rectangle {
background: purple;
border-radius: 20px;
ta := TouchArea {
clicked => {
root.clicked();
}
}
states [
active when ta.has-hover : {
background : #ff71f3;
}
]
}
}
export component TextInput {
in-out property <string> text : "abcdefghijklmnopqrstuvwxyzabcdefghijklmn";
in-out property <length> font-size : 14px;
in property <length> max-text-height : 150px;
property <length> scroll-height;
property <int> size;
Rectangle { // used to define a background
background: blue;
border-radius: 20px;
//ScrollView {
//height: scroll-height;
//viewport-height: tata.preferred-height;
//width: 100%;
//viewport-width: self.width;
VerticalLayout {
padding: 15px;
horizontal-stretch: 3;
alignment: center;
tata := TextInput {
vertical-alignment: center;
single-line: false;
text: root.text;
height: self.preferred-height;
wrap: word-wrap;
edited => {
root.text = self.text;
}
}
}
//}
Text {
x : 0px;
width: 20px;
text: tata.preferred-height/1px;
}
}
states [
active when tata.preferred-height > max-text-height: {
//texte area is scrollable
scroll-height : max-text-height;
}
active when tata.preferred-height <= max-text-height: {
//texte area is not scrollable
scroll-height : tata.preferred-height;
}
]
}
export component send_area {
property <string> text: "";
callback send(string);
Rectangle {
background: #154481;
}
HorizontalLayout {
padding: 10px;
spacing: 10px;
TextInput { width: 80%; }
SendButton{
horizontal-stretch: 1;
clicked => {
send(text);
}
}
}
}
export component Demo inherits Window{
min-height: 400px;
VerticalLayout {
Rectangle {
background: red; // message area
}
send_area {
}
}
} |
Beta Was this translation helpful? Give feedback.
-
I finally found something that seems to work. It seems that this require to force the size of both the rectangle and the scrollview. export component TestScrollViewWithText {
property <string> text: "test";
property <length> scroll-height;
property <length> max-text-height : 100px;
in property <length> tpadding: 15px;
height: 300px;
width: 100px;
VerticalLayout {
Rectangle {
background: red;
}
Rectangle {
background: blue;
border-radius: 10px;
height: scroll-height + 2 * tpadding;
ScrollView {
height: scroll-height + 2 * tpadding;
viewport-height: tata.preferred-height + 2 * tpadding;
width: 100%;
viewport-width: self.width;
VerticalLayout {
padding: tpadding;
alignment: center;
tata := TextInput {
vertical-alignment: center;
single-line: false;
text: root.text;
height: self.preferred-height;
wrap: word-wrap;
edited => {
root.text = self.text;
}
}
}
}
}
}
states [
active when tata.preferred-height > max-text-height: {
//texte area is scrollable
scroll-height : max-text-height;
}
active when tata.preferred-height <= max-text-height: {
//texte area is not scrollable
scroll-height : tata.preferred-height;
}
]
} |
Beta Was this translation helpful? Give feedback.
I finally found something that seems to work.
It seems that this require to force the size of both the rectangle and the scrollview.
not forgetting to take padding into account