TextInput and scroll view keep cursor visible #9168
Unanswered
moolight-seashell
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Let me be your import { AboutSlint, VerticalBox, ScrollView, TextEdit, StyleMetrics } from "std-widgets.slint";
export component Demo {
preferred-height: 300px;
preferred-width: 300px;
layout := VerticalBox {
Text {
text: "Hello Chat!";
font-size: 24px;
horizontal-alignment: center;
}
AboutSlint {
preferred-height: 150px;
}
// In this example serves as a "spacer" item
chat-view := Rectangle { vertical-stretch: 1; color: blue; }
chat-edit := TextEdit {
// We cannot use a layout here (because TextEdit is high-level component)
padding: StyleMetrics.layout-padding;
// NOTE: This would "grow" the component to a certain height.
// Results in a binding loop and cannot be worked around.
// preferred-height: self.viewport-height;
min-height: self.font-size + 2 * self.padding;
max-height: 150px;
}
}
} You are correct TextEdit does not allow to customize "grow" behaviour currently. Consider asking that question and maybe the developers will find that an interesting feature and implement it for you leaving you with less of a headache… |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I've try to design a texte area for a chat apps.
this widget is kind of complicated because it should be able to grow , and becoming scrollable when there is to much text
My current solution is working exept for the scroll :
when there is enough text to make the widget scrollable
if the user add more text , for example at the bottom of the view, the scrollview neet to
the thing is when the user type some text ,the scroll view must follow this new content and stick to the bottom.
But this is only true if the user is at the end of the text.
If the user adds text in the middle, automatically sliding the scroll view to keep the cursor in view seems impossible to do.
To do this, we would need to know:
The physical height of a line of text.
The number of lines of text displayed (taking word wrap into account).
The displayed position of the cursor. (taking word wrap into account).
But we would also need a callback when the scroll view changes size.
Or maybe there is a other way to achieve this ?
And TextEdit is not really an option because it cannot dynamycly reize like TextEdit
Beta Was this translation helpful? Give feedback.
All reactions