如何在 FLEX 表单项标签中嵌入图像
我需要在表单中的标签左侧添加一个图标。 如果图标是标签的一部分,效果可能会最好。 在我看来,表单项的左侧标签之前不能有任何内容,这附近还有吗?
I need to include an icon to the left of a label in my form. it would probably work best if the icon was part of the label. it seems to me that a form item cannot have anything preceed the label on the left side, is there anyway around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您查看 formItem 的源代码,它有两个子项。 一个是标签,另一个是指示器皮肤。 因此,如果不扩展 formItem 类或使用 Grid 等不同的东西(这将提供类似的布局),则添加图标/图像是不可能的,但这显然不包括表单具有的任何功能(例如必填字段等。
请查看这篇有关扩展 FormItem 以包含图像/图标的文章。
http://kennethsutherland.com/2009/05/27/formitem -adding-an-icon/
我编辑了这篇文章,因为我想了一下我之前的答案是垃圾:)
该博客文章将允许您将图像添加到 formItem。
If you check out the source code for the formItem it has two children. one is the label and the other is the indicatorSkin. So adding an icon/image isn't going to be possible without extending the formItem class or going with something different like the Grid (which will give a similar layout), but this will obviously not include any of the features that the form has (such as required fields etc.
check out this post on extending the FormItem to include an image/icon.
http://kennethsutherland.com/2009/05/27/formitem-adding-an-icon/
I've edit this post as after a bit of thought my previous answer was crap :)
The blog post will let you add an image to the formItem.
最好的办法是扩展 FormItem 类并添加一个属性,以便您可以指定要显示的图像。 然后重写 commitProperties()、measure() 和 updateDisplayList() 来创建图标,分别设置组件的首选大小和位置图标。
Your best bet is to extend the FormItem class and add a property so you can specify the image to be displayed. Then override commitProperties(), measure() and updateDisplayList() to create the icon, set the component's preferred size and position the icon, respectively.
应该说这是一个 FLEX 问题
Should have said this is a FLEX question