如何在Spark TextArea中的每行文本下显示一行 [英] How can I show a line under each row of text in a Spark TextArea
问题描述
实际上,在Flex 3中遇到了类似的问题去除了作为我们样式一部分的禁用链接按钮。刚刚检查了代码,并查看火花标签的文档,发现我使用的是一个mx标签的函数明确表示,它不会工作[火花标签中的measureText()]:
度量指定的文本,假设它显示在
单行UITextField(或UIFTETextField)中,使用由样式确定的UITextFormat
这个UIComponent。由于不使用UITextField(或UIFTETextField),因此不适用于Spark
组件。要
测量Spark组件中的文本,获取
的测量值spark.components.Label或spark.components.RichText
$ b $所以我重新计算出来:
<?xml version =1.0encoding =utf- 8\" >?;
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函数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:声明>
<! - 在这里放置非可视元素(例如服务,值对象) - >
< / fx:声明>
< / s:标签>
I'm trying to show a horizontal line under each row of text in a Spark TextArea. I want to give the text area the look of legal paper.
Ah actually ran into a similar problem in Flex 3 doing a strikeout for a disabled link-button that was part of our styles. Just checked out the code and looked on the docs for the spark label and found the function I was using from a mx label explicitly says it won't work [from measureText() in spark label]:
Measures the specified text, assuming that it is displayed in a single-line UITextField (or UIFTETextField) using a UITextFormat determined by the styles of this UIComponent. Does not work for Spark components since they don't use UITextField (or UIFTETextField). To measure text in Spark components, get the measurements of a spark.components.Label or spark.components.RichText
So I re-figured it out:
<?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 (e.g., services, value objects) here -->
</fx:Declarations>
</s:Label>
这篇关于如何在Spark TextArea中的每行文本下显示一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!