Flex验证器弹出窗口位于令人惊讶的位置。我可以调整一下吗?

时间:2012-01-26 14:15:00

标签: flex validation

这是一个最小的Flex应用程序,它具有RichEditableText长度的验证器:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               xmlns:s="library://ns.adobe.com/flex/spark"
               minWidth="955" minHeight="600"
               >
    <fx:Declarations>
        <mx:NumberValidator id="titleLenValidator"
                            exceedsMaxError="Your text is too long. As a result some of it is not shown."
                            maxValue="60"
                            property="contentHeight"
                            source="{titleLabel}"
                            >
        </mx:NumberValidator>
    </fx:Declarations>
    <s:RichEditableText id="titleLabel"
                        text="very long very long very long very long very long very long very long very long very long very long very long very long very long very long very long very long very long very long very long very long very long very long very long "
                        maxHeight="40" width="400"
                        y="400"
                        fontSize="20"
                        >
    </s:RichEditableText>
    <s:Button>
    </s:Button>
</s:Application>

问题是,当文本框的内容向下滚动时,验证器随之向上移动,最终结果如下所示:

enter image description here

如何调整验证器弹出窗口的位置,使其不在内容的位置之上,而是在控件本身的顶部?

1 个答案:

答案 0 :(得分:1)

对于spark表单验证,你应该将RichEditableText包装到FormItem中,以防你需要一些自定义布局(例如非默认位置的错误字符串) - 你应该为FormItem创建外观并更改内部布局(例如更改错误字符串标签位置)