/ LJCJSCodeDoc / LJCCommonLib / LJC / GetTextCols


Parameters
width - A width value.
widthDivisor - The number of units by which to divide the width.

Returns

The text area column count.

Syntax

JavaScript
static GetTextCols(width, widthDivisor)

Gets the textarea columns.

Example

JavaScript
<body>
  <!-- The dialog for debug or other display text. -->
  <dialog id="textDialog"
    style="border: none; padding: 0px">
    <textarea id="textArea" rows="25" cols="80" autocorrect="off"
      autocapitalize="off" spellcheck="false" readonly
      style="border: none; padding: 10px">
    </textarea>
  </dialog>
</body>

// Gets the textarea columns.
GetTextCols()
{
  const className = "ClassName";
  const methodName = "MethodName()";
  const valueName = "text";
  const value = "This is the\r\nthree line\r\ntext value.";
  const force = false;
  const textDialogID = "textDialog";
  const textAreaID = "textArea";
  LJC.ShowText(className, methodName, valueName, value, force, textDialogID
    , textAreaID);

  const eTextArea = LJC.Element(textAreaID);
  const font = LJC.ElementStyle(eTextArea, "font");
  const averageCharWidth = LJC.AverageFontCharWidth(font, value);

  const characterCount = 40;
  const clientWidth = characterCount * averageCharWidth;
  const columns = 1;

  eTextArea.cols = LJC.GetTextCols(clientWidth, columns, averageCharWidth);
  LJC.SetTextRows(eTextArea);
}

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.