how to count visible lines in textArea?

5 visualizaciones (últimos 30 días)
Jiri Hajek
Jiri Hajek el 29 de Jun. de 2022
Comentada: Jiri Hajek el 30 de Jun. de 2022
I have a long text in Text Area, which is too long to fit. As the app window and the text area is changing size (possibly also font size), the text is partially hidden. I'd like to know, how many lines of text are actually visible.

Respuestas (1)

Image Analyst
Image Analyst el 29 de Jun. de 2022
I'd take a vertical profile and threshold it. You forgot to attach your picture. But if you have an image with black text on a white background
verticalProfile = mean(grayImage, 2);
mask = verticalProfile < 128;
[labeledLines, numberOfLines] = bwlabel(mask)
  1 comentario
Jiri Hajek
Jiri Hajek el 30 de Jun. de 2022
This is an interesting idea, but I'm not sure if it can be directly applied to an uiTextArea, which is not an image, but a live text field. It is further embedded into an app, which has many more components (buttons, labels, text fields, axes, tabs), so to analyze the app GUI as an image would be difficult, although perhaps viable using "exportapp" function.
My information readily available is the text content as a cell array and properties of the uiTextArea, which I hoped could be sufficient. Perhaps I could make an analysis of a sample text to get an approximate relationship between the size in pixels, font size and number of visible lines...

Iniciar sesión para comentar.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by