How to get the total horizontal width in Label, Button, TextArea or TextBox characters?

Shortcut, Button, TextArea and TextBox (abbreviated LBTT from now on) are capable of displaying lines of text. Is there a way to look at an LBTT object with an already set size and determine the number of characters that can correspond to each line of this object.

For example, let's say that I have textArea, which is fixed in its width. Is there a way to set this textArea object, how many characters can it hold horizontally? Conceptually, something like .getHorizontalCharacterWidth () method?

Here is my "visual" ascii Label example. "-" and "|" must represent the vertical and horizontal edges of the label, respectively.

 -------
|       |
|ABCDEFG|
|       |
 -------

As you can see, this label can contain up to 7 characters per horizontal line (in this case AG)? So if you name my imaginary .getHorizontalCharacterWidth () on this label, it will return 7. The question is, how are you going to implement .getHorizontalCharacterWidth ()?

Suppose I use a fixed-width font.

thank

+3
source share
3 answers

, , , aTextArea.getCharacterWidth() , . html- cols, ( aTextArea.setCharacterWidth()), CSS.

, , , , . , / , , .

+3

html-.

:

<textarea name="" cols="10" rows=""></textarea>

:

<input name="" type="text" size="10" />

, . , "i" , "m". , , , , , .

0

, - .

, .

- HTML, , .

0

Source: https://habr.com/ru/post/1733837/


All Articles