简体   繁体   English

扩展 Flex3 的面板:在自定义组件中计算标题的宽度

[英]Extending Flex3's Panel: Calculating Title's Width in Custom Component

Hi I'm extending the Flex 3 panel component.您好,我正在扩展 Flex 3 面板组件。 I need to figure out the width of the title's text.我需要弄清楚标题文本的宽度。 Because, title is a private variable in panel, I can't access it via title.width.因为,title 是面板中的私有变量,所以我无法通过 title.width 访问它。

I know the font, fontsize (14), and length of the title (which will vary).我知道标题的字体、字体大小 (14) 和长度(会有所不同)。 Knowing this info is there a way to calculate how many pixels wide the title is?知道这个信息有没有办法计算标题有多少像素宽?

titleTextField is a protected property.You can use it to calculate the textwidth right. titleTextField是一个受保护的属性。您可以使用它来计算 textwidth 的权利。

Can you try this and let me know if it works?你能试试这个,让我知道它是否有效吗?

measureText(titleTextField.text).width

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM