How can I show a line below each line of text in Spark TextArea

I am trying to show a horizontal line below each line of text in Spark TextArea. I want to give the text area the look of legal paper.

+1
source share
2 answers

But in fact, I encountered a similar problem in Flex 3, performing an out for a disabled link button, which was part of our styles. I just checked the code and looked through the documents for the spark label and found that the function that I used with the mx label clearly says that it will not work [from measureText () in the spark label]:

Measures the specified text, assuming that it maps to a single-line UITextField (or UIFTETextField) using a UITextFormat defined by the styles of this UIComponent. This does not work for Spark because they do not use UITextField (or UIFTETextField). To measure text in Spark components, get spark.components.Label or spark.components.RichText measurements

So, I rethought this:

<?xml version="1.0" encoding="utf-8"?> <s:Label xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"> <fx:Script> <![CDATA[ override protected function updateDisplayList(unscaledWidth : Number, unscaledHeight : Number) : void { super.updateDisplayList(unscaledWidth, unscaledHeight); drawLines(); } private function drawLines() : void { var totalHeight : Number = 0; for (var i : int = 0; i < mx_internal::textLines.length; i++) { totalHeight = mx_internal::textLines[i].y; graphics.lineStyle(1, 0x000000); graphics.moveTo(0, totalHeight); graphics.lineTo(width, totalHeight); } } ]]> </fx:Script> <fx:Declarations> <!-- Place non-visual elements (eg, services, value objects) here --> </fx:Declarations> </s:Label> 
+2
source

Set the textDecoration style for the control.

+2
source

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


All Articles